Commit a89527e1 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-31827 InnoDB multi-batch recovery stops prematurely

recv_scan_log(): On recv_sys_t::PREMATURE_EOF, keep reading more log
if recv_sys.lsn < recv_sys.scanned_lsn.

recv_recovery_from_checkpoint_start(): Add a safety check to abort
crash recovery if recv_sys.lsn is not recv_sys.scanned_lsn.

This fixes a serious database corruption bug that was introduced by
commit 2f9e2647 (MDEV-29911).
parent 8760fe11
...@@ -4147,7 +4147,8 @@ static bool recv_scan_log(bool last_phase) ...@@ -4147,7 +4147,8 @@ static bool recv_scan_log(bool last_phase)
if (recv_sys.is_corrupt_log()) if (recv_sys.is_corrupt_log())
break; break;
if (recv_sys.offset < log_sys.get_block_size()) if (recv_sys.offset < log_sys.get_block_size() &&
recv_sys.lsn == recv_sys.scanned_lsn)
goto got_eof; goto got_eof;
if (recv_sys.offset > buf_size / 4 || if (recv_sys.offset > buf_size / 4 ||
...@@ -4662,6 +4663,13 @@ dberr_t recv_recovery_from_checkpoint_start() ...@@ -4662,6 +4663,13 @@ dberr_t recv_recovery_from_checkpoint_start()
} }
mysql_mutex_lock(&recv_sys.mutex); mysql_mutex_lock(&recv_sys.mutex);
if (UNIV_UNLIKELY(recv_sys.scanned_lsn != recv_sys.lsn)
&& log_sys.is_latest()) {
ut_ad("log parsing error" == 0);
mysql_mutex_unlock(&recv_sys.mutex);
err = DB_CORRUPTION;
goto early_exit;
}
recv_sys.apply_log_recs = true; recv_sys.apply_log_recs = true;
recv_no_ibuf_operations = false; recv_no_ibuf_operations = false;
ut_d(recv_no_log_write = srv_operation == SRV_OPERATION_RESTORE ut_d(recv_no_log_write = srv_operation == SRV_OPERATION_RESTORE
......
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