Skip to content

Commit

Permalink
MDEV-26811: Assertion "log_sys->n_pending_flushes == 1" fails
Browse files Browse the repository at this point in the history
In commit 1cb218c (MDEV-26450)
we introduced the function log_write_and_flush(), which may
compete with log_checkpoint() invoking log_write_flush_to_disk_low()
from another thread.

The assertion n_pending_flushes==1 is too strict.
There is no possibility of a race condition here, because
fil_flush() is protected by fil_system->mutex and the
rest will be protected by log_sys->mutex.

log_write_flush_to_disk_low(), log_write_and_flush():
Relax the assertions to test for a nonzero count.
  • Loading branch information
dr-m committed Oct 13, 2021
1 parent 6f32b28 commit 2bb8d7c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -983,21 +983,16 @@ log_group_write_buf(

/** Flush the recently written changes to the log file.
and invoke log_mutex_enter(). */
static
void
log_write_flush_to_disk_low()
static void log_write_flush_to_disk_low()
{
/* FIXME: This is not holding log_sys->mutex while
calling os_event_set()! */
ut_a(log_sys->n_pending_flushes == 1); /* No other threads here */
ut_a(log_sys->n_pending_flushes);

bool do_flush = srv_file_flush_method != SRV_O_DSYNC;

if (do_flush) {
fil_flush(SRV_LOG_SPACE_FIRST_ID);
}


log_mutex_enter();
if (do_flush) {
log_sys->flushed_to_disk_lsn = log_sys->current_flush_lsn;
Expand Down Expand Up @@ -1329,7 +1324,7 @@ ATTRIBUTE_COLD void log_write_and_flush()

/* Code adapted from log_write_flush_to_disk_low() */

ut_a(log_sys->n_pending_flushes == 1); /* No other threads here */
ut_a(log_sys->n_pending_flushes);

if (srv_file_flush_method != SRV_O_DSYNC)
fil_flush(SRV_LOG_SPACE_FIRST_ID);
Expand Down

0 comments on commit 2bb8d7c

Please sign in to comment.