From 27309fc6b0833d7a74baab4afaeef1dcb14307c8 Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Tue, 14 Jun 2022 11:31:11 +0300 Subject: MDEV-28832 infinite loop in mariabackup if log LOG_HEADER_FORMAT field is 0 Avoid the loop with getting rid of back and forth jumping. --- extra/mariabackup/xtrabackup.cc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 13319f44969..37c80baf32f 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -4524,32 +4524,32 @@ fail: reread_log_header: dberr_t err = recv_find_max_checkpoint(&max_cp_field); - if (err != DB_SUCCESS) { + if (err != DB_SUCCESS) msg("Error: cannot read redo log header"); -unlock_and_fail: - mysql_mutex_unlock(&log_sys.mutex); - } - - if (log_sys.log.format == 0) { + else if (log_sys.log.format == 0) { msg("Error: cannot process redo log before MariaDB 10.2.2"); - goto unlock_and_fail; + err = DB_ERROR; } + else { + byte* buf = log_sys.checkpoint_buf; + checkpoint_lsn_start = log_sys.log.get_lsn(); + checkpoint_no_start = log_sys.next_checkpoint_no; - byte* buf = log_sys.checkpoint_buf; - checkpoint_lsn_start = log_sys.log.get_lsn(); - checkpoint_no_start = log_sys.next_checkpoint_no; - - log_sys.log.read(max_cp_field, {buf, OS_FILE_LOG_BLOCK_SIZE}); - - if (checkpoint_no_start != mach_read_from_8(buf + LOG_CHECKPOINT_NO) - || checkpoint_lsn_start - != mach_read_from_8(buf + LOG_CHECKPOINT_LSN) - || log_sys.log.get_lsn_offset() - != mach_read_from_8(buf + LOG_CHECKPOINT_OFFSET)) - goto reread_log_header; + log_sys.log.read(max_cp_field, {buf, OS_FILE_LOG_BLOCK_SIZE}); + if (checkpoint_no_start + != mach_read_from_8(buf + LOG_CHECKPOINT_NO) + || checkpoint_lsn_start + != mach_read_from_8(buf + LOG_CHECKPOINT_LSN) + || log_sys.log.get_lsn_offset() + != mach_read_from_8(buf + LOG_CHECKPOINT_OFFSET)) + goto reread_log_header; + } mysql_mutex_unlock(&log_sys.mutex); + if (err != DB_SUCCESS) + goto fail; + xtrabackup_init_datasinks(); if (!select_history()) { -- cgit v1.2.1