summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-03-30 09:58:24 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-30 10:29:11 +0300
commit8c2e3259c13d1d0a494fb3f9c1e5fb780a193ab1 (patch)
treee8e644ab993da47feec3982913f050a51a0b5066 /include
parent0df74a0197a5c2acf50645516fbf6bf20ad7e27f (diff)
downloadmariadb-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 'include')
-rw-r--r--include/my_atomic_wrapper.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/my_atomic_wrapper.h b/include/my_atomic_wrapper.h
index c574fba4a8e..d57559d360d 100644
--- a/include/my_atomic_wrapper.h
+++ b/include/my_atomic_wrapper.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2020, MariaDB
+/* Copyright (c) 2020, 2021, MariaDB
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
@@ -41,7 +41,9 @@ public:
Atomic_relaxed(Type val) : m(val) {}
Atomic_relaxed() {}
- operator Type() const { return m.load(std::memory_order_relaxed); }
+ Type load(std::memory_order o= std::memory_order_relaxed) const
+ { return m.load(o); }
+ operator Type() const { return m.load(); }
Type operator=(const Type val)
{ m.store(val, std::memory_order_relaxed); return val; }
Type operator=(const Atomic_relaxed<Type> &rhs) { return *this= Type{rhs}; }