Commit 42609c24 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Replace log_sys.n_pending_checkpoint_writes with a Boolean

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.
parent b7016bd3
......@@ -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);
......
......@@ -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;
/** next checkpoint LSN (protected by log_sys.mutex) */
lsn_t next_checkpoint_lsn;
/*!< next checkpoint lsn */
ulint n_pending_checkpoint_writes;
/*!< number of currently pending
checkpoint writes */
/** whether a checkpoint is pending */
Atomic_relaxed<bool> checkpoint_pending;
/** buffer for checkpoint header */
byte *checkpoint_buf;
......
......@@ -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);
......@@ -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);
......@@ -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++;
......@@ -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) {
......@@ -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)
......
......@@ -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
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment