Commit 63b9d6e7 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Restore the MDEV-26789 logic, partially lost in refactoring.

parent 3553cfd0
...@@ -519,7 +519,8 @@ inline void log_t::persist(lsn_t lsn) noexcept ...@@ -519,7 +519,8 @@ inline void log_t::persist(lsn_t lsn) noexcept
/** Write buf to ib_logfile0. /** Write buf to ib_logfile0.
@tparam release_latch whether to invoke latch.wr_unlock() @tparam release_latch whether to invoke latch.wr_unlock()
@return new write target @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 template<bool release_latch> inline lsn_t log_t::write_buf() noexcept
{ {
ut_ad(latch.is_write_locked()); ut_ad(latch.is_write_locked());
...@@ -605,7 +606,9 @@ inline bool log_t::flush(lsn_t lsn) noexcept ...@@ -605,7 +606,9 @@ inline bool log_t::flush(lsn_t lsn) noexcept
/** Ensure that previous log writes are durable. /** Ensure that previous log writes are durable.
@param lsn previously written LSN @param lsn previously written LSN
@return new durable lsn target @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) static lsn_t log_flush(lsn_t lsn)
{ {
ut_ad(!log_sys.is_pmem()); ut_ad(!log_sys.is_pmem());
...@@ -653,29 +656,27 @@ void log_write_up_to(lsn_t lsn, bool durable, ...@@ -653,29 +656,27 @@ void log_write_up_to(lsn_t lsn, bool durable,
flush_lock.acquire(lsn, callback) != group_commit_lock::ACQUIRED) flush_lock.acquire(lsn, callback) != group_commit_lock::ACQUIRED)
return; return;
lsn_t write_lsn; lsn_t pending_write_lsn= 0, pending_flush_lsn= 0;
if (write_lock.acquire(lsn, durable ? nullptr : callback) == if (write_lock.acquire(lsn, durable ? nullptr : callback) ==
group_commit_lock::ACQUIRED) group_commit_lock::ACQUIRED)
{ {
log_sys.latch.wr_lock(SRW_LOCK_CALL); 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) if (durable)
{ {
lsn= log_flush(write_lock.value()); pending_flush_lsn= log_flush(write_lock.value());
if (lsn || write_lsn) }
if (pending_write_lsn || pending_flush_lsn)
{ {
/* There is no new group commit lead; some async waiters could stall. */ /* There is no new group commit lead; some async waiters could stall. */
callback= &dummy_callback; callback= &dummy_callback;
if (write_lsn > lsn) lsn= std::max(pending_write_lsn, pending_flush_lsn);
lsn= write_lsn;
goto repeat; goto repeat;
} }
}
} }
/** Write to the log file up to the last log entry. /** Write to the log file up to the last log entry.
...@@ -704,8 +705,12 @@ ATTRIBUTE_COLD void log_write_and_flush() ...@@ -704,8 +705,12 @@ ATTRIBUTE_COLD void log_write_and_flush()
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
if (!log_sys.is_pmem()) if (!log_sys.is_pmem())
{ {
log_sys.write_buf<false>(); while (log_sys.write_buf<false>())
log_flush(write_lock.value()); {
}
while (log_flush(write_lock.value()))
{
}
} }
#ifdef HAVE_PMEM #ifdef HAVE_PMEM
else else
......
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