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

Follow-up to MDEV-16367 mariabackup: error: failed to copy enough redo log

Commit dc9c5554 moved the final phase of
the redo log copying to the background thread. This would sometimes cause
too little redo log to be copied at the end of the backup. We would only
guarantee copying up to the latest redo log checkpoint. This would produce
a consistent backup, but it could refer to a too old point of time.

xtrabackup_copy_log(), xtrabackup_copy_logfile(): Add the parameter 'last'.

xtrabackup_backup_low(): Copy any remaining part of the log after the
backup threads have terminated.
parent 6b8802e8
...@@ -2469,9 +2469,10 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n) ...@@ -2469,9 +2469,10 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
/** Copy redo log blocks to the data sink. /** Copy redo log blocks to the data sink.
@param start_lsn buffer start LSN @param start_lsn buffer start LSN
@param end_lsn buffer end LSN @param end_lsn buffer end LSN
@param last whether we are copying the final part of the log
@return last scanned LSN @return last scanned LSN
@retval 0 on failure */ @retval 0 on failure */
static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn) static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn, bool last)
{ {
lsn_t scanned_lsn = start_lsn; lsn_t scanned_lsn = start_lsn;
const byte* log_block = log_sys->buf; const byte* log_block = log_sys->buf;
...@@ -2530,7 +2531,7 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn) ...@@ -2530,7 +2531,7 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn)
log_sys->log.scanned_lsn = scanned_lsn; log_sys->log.scanned_lsn = scanned_lsn;
end_lsn = metadata_to_lsn end_lsn = last
? ut_uint64_align_up(scanned_lsn, OS_FILE_LOG_BLOCK_SIZE) ? ut_uint64_align_up(scanned_lsn, OS_FILE_LOG_BLOCK_SIZE)
: scanned_lsn & ~lsn_t(OS_FILE_LOG_BLOCK_SIZE - 1); : scanned_lsn & ~lsn_t(OS_FILE_LOG_BLOCK_SIZE - 1);
...@@ -2550,8 +2551,9 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn) ...@@ -2550,8 +2551,9 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn)
} }
/** Copy redo log until the current end of the log is reached /** Copy redo log until the current end of the log is reached
@param last whether we are copying the final part of the log
@return whether the operation failed */ @return whether the operation failed */
static bool xtrabackup_copy_logfile() static bool xtrabackup_copy_logfile(bool last = false)
{ {
ut_a(dst_log_file != NULL); ut_a(dst_log_file != NULL);
ut_ad(recv_sys != NULL); ut_ad(recv_sys != NULL);
...@@ -2582,7 +2584,7 @@ static bool xtrabackup_copy_logfile() ...@@ -2582,7 +2584,7 @@ static bool xtrabackup_copy_logfile()
} }
start_lsn = (lsn == start_lsn) start_lsn = (lsn == start_lsn)
? 0 : xtrabackup_copy_log(start_lsn, lsn); ? 0 : xtrabackup_copy_log(start_lsn, lsn, last);
log_mutex_exit(); log_mutex_exit();
...@@ -3726,6 +3728,11 @@ static bool xtrabackup_backup_low() ...@@ -3726,6 +3728,11 @@ static bool xtrabackup_backup_low()
stop_backup_threads(); stop_backup_threads();
if (metadata_to_lsn && xtrabackup_copy_logfile(true)) {
ds_close(dst_log_file);
return false;
}
if (ds_close(dst_log_file) || !metadata_to_lsn) { if (ds_close(dst_log_file) || !metadata_to_lsn) {
dst_log_file = NULL; dst_log_file = NULL;
return false; return false;
......
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