diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-03-30 09:58:24 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-03-30 10:29:11 +0300 |
commit | 8c2e3259c13d1d0a494fb3f9c1e5fb780a193ab1 (patch) | |
tree | e8e644ab993da47feec3982913f050a51a0b5066 /storage/innobase/include | |
parent | 0df74a0197a5c2acf50645516fbf6bf20ad7e27f (diff) | |
download | mariadb-git-8c2e3259c13d1d0a494fb3f9c1e5fb780a193ab1.tar.gz |
MDEV-24302 follow-up: RESET MASTER hangsbb-10.5-MDEV-24302
As pointed out by Andrei Elkin, the previous fix did not fix one
race condition that may have caused the observed hang.
innodb_log_flush_request(): If we are enqueueing the very first
request at the same time the log write is being completed,
we must ensure that a near-concurrent call to log_flush_notify()
will not result in a missed notification. We guarantee this by
release-acquire operations on log_requests.start and
log_sys.flushed_to_disk_lsn.
log_flush_notify_and_unlock(): Cleanup: Always release the mutex.
log_sys_t::get_flushed_lsn(): Use acquire memory order.
log_sys_t::set_flushed_lsn(): Use release memory order.
log_sys_t::set_lsn(): Use release memory order.
log_sys_t::get_lsn(): Use relaxed memory order by default, and
allow the caller to specify acquire memory order explicitly.
Whenever the log_sys.mutex is being held or when log writes are
prohibited during startup, we can use a relaxed load. Likewise,
in some assertions where reading a stale value of log_sys.lsn
should not matter, we can use a relaxed load.
This will cause some additional instructions to be emitted on
architectures that do not implement Total Store Ordering (TSO),
such as POWER, ARM, and RISC-V Weak Memory Ordering (RVWMO).
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/log0log.h | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 1a79738bc9b..849485eae5a 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2009, Google Inc. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -87,12 +87,6 @@ log_free_check(void); @param[in] len requested minimum size in bytes */ void log_buffer_extend(ulong len); -/** Read the current LSN. */ -#define log_get_lsn() log_sys.get_lsn() - -/** Read the durable LSN */ -#define log_get_flush_lsn() log_sys.get_flushed_lsn() - /** Calculate the recommended highest values for lsn - last_checkpoint_lsn and lsn - buf_pool.get_oldest_modification(). @param[in] file_size requested innodb_log_file_size @@ -646,13 +640,14 @@ public: bool is_initialised() const { return m_initialised; } - lsn_t get_lsn() const { return lsn.load(std::memory_order_relaxed); } - void set_lsn(lsn_t lsn) { this->lsn.store(lsn, std::memory_order_relaxed); } + lsn_t get_lsn(std::memory_order order= std::memory_order_relaxed) const + { return lsn.load(order); } + void set_lsn(lsn_t lsn) { this->lsn.store(lsn, std::memory_order_release); } lsn_t get_flushed_lsn() const - { return flushed_to_disk_lsn.load(std::memory_order_relaxed); } + { return flushed_to_disk_lsn.load(std::memory_order_acquire); } void set_flushed_lsn(lsn_t lsn) - { flushed_to_disk_lsn.store(lsn, std::memory_order_relaxed); } + { flushed_to_disk_lsn.store(lsn, std::memory_order_release); } bool check_flush_or_checkpoint() const { |