Skip to content

Commit c64e507

Browse files
committed
MDEV-27621 Backup fails with FATAL ERROR: Was only able to copy log
In commit 685d958 (MDEV-14425) a bug was introduced to mariadb-backup --backup for the case when the log is wrapping around to log_sys.START_OFFSET (12288). This could also cause a "Missing FILE_CHECKPOINT" error during mariadb-backup --prepare, in case the log copying resumed after the server had produced a multiple of innodb_log_file_size-12288 bytes of more log so that the last mini-transaction would end exactly at the end of the log file. xtrabackup_copy_logfile(): If the log wraps around, read everything to the end of the log file, and then the rest from log_sys.START_OFFSET.
1 parent 79e3ee0 commit c64e507

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB
44
Originally Created 3/3/2009 Yasufumi Kinoshita
55
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
66
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
7-
(c) 2017, 2021, MariaDB Corporation.
7+
(c) 2017, 2022, MariaDB Corporation.
88
Portions written by Marko Mäkelä.
99
1010
This program is free software; you can redistribute it and/or modify
@@ -3002,10 +3002,21 @@ static bool xtrabackup_copy_logfile()
30023002
recv_sys.offset);
30033003
source_offset&= ~block_size_1;
30043004
size_t size{log_sys.buf_size - recv_sys.len};
3005-
if (source_offset + size > log_sys.file_size)
3006-
size= static_cast<size_t>(log_sys.file_size - source_offset);
3007-
ut_ad(size <= log_sys.buf_size);
3008-
log_sys.log.read(source_offset, {log_sys.buf, size});
3005+
if (UNIV_UNLIKELY(source_offset + size > log_sys.file_size))
3006+
{
3007+
const size_t first{size_t(log_sys.file_size - source_offset)};
3008+
ut_ad(first <= log_sys.buf_size);
3009+
log_sys.log.read(source_offset, {log_sys.buf, first});
3010+
size-= first;
3011+
if (log_sys.START_OFFSET + size > source_offset)
3012+
size= size_t(source_offset - log_sys.START_OFFSET);
3013+
if (size)
3014+
log_sys.log.read(log_sys.START_OFFSET,
3015+
{log_sys.buf + first, size});
3016+
size+= first;
3017+
}
3018+
else
3019+
log_sys.log.read(source_offset, {log_sys.buf, size});
30093020
recv_sys.len= size;
30103021
}
30113022

0 commit comments

Comments
 (0)