Skip to content

Commit 1495f05

Browse files
committed
MDEV-30860 Race condition between buffer pool flush and log file deletion in mariadb-backup --prepare
srv_start(): If we are going to close the log file in mariadb-backup --prepare, call buf_flush_sync() before calling recv_sys.debug_free() to ensure that the log file will not be accessed. This fixes a rather rare failure in the test mariabackup.innodb_force_recovery where buf_flush_page_cleaner() would invoke log_checkpoint_low() because !recv_recovery_is_on() would hold due to the fact that recv_sys.debug_free() had already been called. Then, the log write for the checkpoint would fail because srv_start() had invoked log_sys.log.close_file().
1 parent 7d6b3d4 commit 1495f05

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

storage/innobase/srv/srv0start.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,7 @@ static lsn_t srv_prepare_to_delete_redo_log_file(bool old_exists)
922922
{
923923
DBUG_ENTER("srv_prepare_to_delete_redo_log_file");
924924

925-
/* Disable checkpoints in the page cleaner. */
926-
ut_ad(!recv_sys.recovery_on);
927-
recv_sys.recovery_on= true;
925+
ut_ad(recv_sys.recovery_on);
928926

929927
/* Clean the buffer pool. */
930928
buf_flush_sync();
@@ -1606,10 +1604,10 @@ dberr_t srv_start(bool create_new_db)
16061604
}
16071605
}
16081606

1609-
recv_sys.debug_free();
1610-
16111607
if (srv_operation == SRV_OPERATION_RESTORE
16121608
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT) {
1609+
buf_flush_sync();
1610+
recv_sys.debug_free();
16131611
/* After applying the redo log from
16141612
SRV_OPERATION_BACKUP, flush the changes
16151613
to the data files and truncate or delete the log.
@@ -1701,6 +1699,8 @@ dberr_t srv_start(bool create_new_db)
17011699
return(srv_init_abort(err));
17021700
}
17031701
}
1702+
1703+
recv_sys.debug_free();
17041704
}
17051705

17061706
ut_ad(err == DB_SUCCESS);

0 commit comments

Comments
 (0)