Skip to content

Commit

Permalink
Cleanup: Replace log_sys.n_pending_checkpoint_writes with a Boolean
Browse files Browse the repository at this point in the history
Only one checkpoint may be in progress at a time.
The counter log_sys.n_pending_checkpoint_writes
was being protected by log_sys.mutex.
Let us replace it with the Boolean log_sys.checkpoint_pending.
  • Loading branch information
dr-m committed Mar 29, 2022
1 parent b7016bd commit 42609c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ static bool log_checkpoint_low(lsn_t oldest_lsn, lsn_t end_lsn)

ut_ad(log_sys.get_flushed_lsn() >= flush_lsn);

if (log_sys.n_pending_checkpoint_writes)
if (log_sys.checkpoint_pending)
{
/* A checkpoint write is running */
mysql_mutex_unlock(&log_sys.mutex);
Expand Down
9 changes: 4 additions & 5 deletions storage/innobase/include/log0log.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,10 @@ struct log_t{
/*!< next checkpoint number */
/** latest completed checkpoint (protected by log_sys.mutex) */
Atomic_relaxed<lsn_t> last_checkpoint_lsn;
lsn_t next_checkpoint_lsn;
/*!< next checkpoint lsn */
ulint n_pending_checkpoint_writes;
/*!< number of currently pending
checkpoint writes */
/** next checkpoint LSN (protected by log_sys.mutex) */
lsn_t next_checkpoint_lsn;
/** whether a checkpoint is pending */
Atomic_relaxed<bool> checkpoint_pending;

/** buffer for checkpoint header */
byte *checkpoint_buf;
Expand Down
15 changes: 8 additions & 7 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void log_t::create()
max_checkpoint_age= 0;
next_checkpoint_no= 0;
next_checkpoint_lsn= 0;
n_pending_checkpoint_writes= 0;
checkpoint_pending= false;

log_block_init(buf, LOG_START_LSN);
log_block_set_first_rec_group(buf, LOG_BLOCK_HDR_SIZE);
Expand Down Expand Up @@ -939,7 +939,8 @@ ATTRIBUTE_COLD void log_write_checkpoint_info(lsn_t end_lsn)
ut_ad(LOG_CHECKPOINT_1 < srv_page_size);
ut_ad(LOG_CHECKPOINT_2 < srv_page_size);

++log_sys.n_pending_checkpoint_writes;
ut_ad(!log_sys.checkpoint_pending);
log_sys.checkpoint_pending = true;

mysql_mutex_unlock(&log_sys.mutex);

Expand All @@ -954,8 +955,8 @@ ATTRIBUTE_COLD void log_write_checkpoint_info(lsn_t end_lsn)

mysql_mutex_lock(&log_sys.mutex);

--log_sys.n_pending_checkpoint_writes;
ut_ad(log_sys.n_pending_checkpoint_writes == 0);
ut_ad(log_sys.checkpoint_pending);
log_sys.checkpoint_pending = false;

log_sys.next_checkpoint_no++;

Expand Down Expand Up @@ -1149,8 +1150,8 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown()

if (log_sys.is_initialised()) {
mysql_mutex_lock(&log_sys.mutex);
const ulint n_write = log_sys.n_pending_checkpoint_writes;
const ulint n_flush = log_sys.pending_flushes;
const size_t n_write{log_sys.checkpoint_pending};
const size_t n_flush{log_sys.get_pending_flushes()};
mysql_mutex_unlock(&log_sys.mutex);

if (n_write || n_flush) {
Expand Down Expand Up @@ -1291,7 +1292,7 @@ log_print(
ULINTPF " pending chkp writes\n"
ULINTPF " log i/o's done, %.2f log i/o's/second\n",
log_sys.pending_flushes.load(),
log_sys.n_pending_checkpoint_writes,
ulint{log_sys.checkpoint_pending},
log_sys.n_log_ios,
static_cast<double>(
log_sys.n_log_ios - log_sys.n_log_ios_old)
Expand Down
7 changes: 2 additions & 5 deletions storage/innobase/srv/srv0mon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2021, MariaDB Corporation.
Copyright (c) 2013, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -1909,10 +1909,7 @@ srv_mon_process_existing_counter(
break;

case MONITOR_PENDING_CHECKPOINT_WRITE:
mysql_mutex_lock(&log_sys.mutex);
value = static_cast<mon_type_t>(
log_sys.n_pending_checkpoint_writes);
mysql_mutex_unlock(&log_sys.mutex);
value = log_sys.checkpoint_pending;
break;

case MONITOR_LOG_IO:
Expand Down

0 comments on commit 42609c2

Please sign in to comment.