From 2bb8d7c2f36439ab6a3944476665eb1218c36f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 13 Oct 2021 10:38:41 +0300 Subject: [PATCH] MDEV-26811: Assertion "log_sys->n_pending_flushes == 1" fails In commit 1cb218c37cc3fe01a1ff2fe9b1cbfb591e90d5ce (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. --- storage/innobase/log/log0log.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 945c97daf4a..8dc29e302dd 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -983,13 +983,9 @@ loop: /** 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; @@ -997,7 +993,6 @@ log_write_flush_to_disk_low() fil_flush(SRV_LOG_SPACE_FIRST_ID); } - log_mutex_enter(); if (do_flush) { log_sys->flushed_to_disk_lsn = log_sys->current_flush_lsn; @@ -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);