Commit 1495f057 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-30860 Race condition between buffer pool flush and log file deletion in...

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().
parent 7d6b3d40
...@@ -922,9 +922,7 @@ static lsn_t srv_prepare_to_delete_redo_log_file(bool old_exists) ...@@ -922,9 +922,7 @@ static lsn_t srv_prepare_to_delete_redo_log_file(bool old_exists)
{ {
DBUG_ENTER("srv_prepare_to_delete_redo_log_file"); DBUG_ENTER("srv_prepare_to_delete_redo_log_file");
/* Disable checkpoints in the page cleaner. */ ut_ad(recv_sys.recovery_on);
ut_ad(!recv_sys.recovery_on);
recv_sys.recovery_on= true;
/* Clean the buffer pool. */ /* Clean the buffer pool. */
buf_flush_sync(); buf_flush_sync();
...@@ -1606,10 +1604,10 @@ dberr_t srv_start(bool create_new_db) ...@@ -1606,10 +1604,10 @@ dberr_t srv_start(bool create_new_db)
} }
} }
recv_sys.debug_free();
if (srv_operation == SRV_OPERATION_RESTORE if (srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT) { || srv_operation == SRV_OPERATION_RESTORE_EXPORT) {
buf_flush_sync();
recv_sys.debug_free();
/* After applying the redo log from /* After applying the redo log from
SRV_OPERATION_BACKUP, flush the changes SRV_OPERATION_BACKUP, flush the changes
to the data files and truncate or delete the log. to the data files and truncate or delete the log.
...@@ -1701,6 +1699,8 @@ dberr_t srv_start(bool create_new_db) ...@@ -1701,6 +1699,8 @@ dberr_t srv_start(bool create_new_db)
return(srv_init_abort(err)); return(srv_init_abort(err));
} }
} }
recv_sys.debug_free();
} }
ut_ad(err == DB_SUCCESS); ut_ad(err == DB_SUCCESS);
......
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