summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2022-02-14 15:39:31 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2022-02-14 15:39:31 +0100
commit63b9d6e7ea77e26b666bc86e8f7aaafba9b40846 (patch)
tree9629d679baa189d910876b7ecca579e9b9848dda
parent3553cfd0254f69f2fbbe3c32601f2a3e2c606ba3 (diff)
downloadmariadb-git-63b9d6e7ea77e26b666bc86e8f7aaafba9b40846.tar.gz
Restore the MDEV-26789 logic, partially lost in refactoring.
-rw-r--r--storage/innobase/log/log0log.cc39
1 files changed, 22 insertions, 17 deletions
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index e0b84285f34..bcf0421e4b6 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -519,7 +519,8 @@ inline void log_t::persist(lsn_t lsn) noexcept
/** Write buf to ib_logfile0.
@tparam release_latch whether to invoke latch.wr_unlock()
@return new write target
-@retval 0 if everything was written */
+@retval lsn of a callback pending on write_lock, or 0
+*/
template<bool release_latch> inline lsn_t log_t::write_buf() noexcept
{
ut_ad(latch.is_write_locked());
@@ -605,7 +606,9 @@ inline bool log_t::flush(lsn_t lsn) noexcept
/** Ensure that previous log writes are durable.
@param lsn previously written LSN
@return new durable lsn target
-@retval 0 if everything was adequately written */
+@retval 0, if there are no pending callbacks on flush_lock
+ or there is another group commit lead.
+*/
static lsn_t log_flush(lsn_t lsn)
{
ut_ad(!log_sys.is_pmem());
@@ -653,28 +656,26 @@ repeat:
flush_lock.acquire(lsn, callback) != group_commit_lock::ACQUIRED)
return;
- lsn_t write_lsn;
+ lsn_t pending_write_lsn= 0, pending_flush_lsn= 0;
if (write_lock.acquire(lsn, durable ? nullptr : callback) ==
group_commit_lock::ACQUIRED)
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
- write_lsn= log_sys.write_buf<true>();
+ pending_write_lsn= log_sys.write_buf<true>();
}
- else
- write_lsn= 0;
if (durable)
{
- lsn= log_flush(write_lock.value());
- if (lsn || write_lsn)
- {
- /* There is no new group commit lead; some async waiters could stall. */
- callback= &dummy_callback;
- if (write_lsn > lsn)
- lsn= write_lsn;
- goto repeat;
- }
+ pending_flush_lsn= log_flush(write_lock.value());
+ }
+
+ if (pending_write_lsn || pending_flush_lsn)
+ {
+ /* There is no new group commit lead; some async waiters could stall. */
+ callback= &dummy_callback;
+ lsn= std::max(pending_write_lsn, pending_flush_lsn);
+ goto repeat;
}
}
@@ -704,8 +705,12 @@ ATTRIBUTE_COLD void log_write_and_flush()
ut_ad(!srv_read_only_mode);
if (!log_sys.is_pmem())
{
- log_sys.write_buf<false>();
- log_flush(write_lock.value());
+ while (log_sys.write_buf<false>())
+ {
+ }
+ while (log_flush(write_lock.value()))
+ {
+ }
}
#ifdef HAVE_PMEM
else