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

MDEV-27621 Backup fails with FATAL ERROR: Was only able to copy log

In commit 685d958e (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.
parent 79e3ee00
...@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB ...@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB
Originally Created 3/3/2009 Yasufumi Kinoshita Originally Created 3/3/2009 Yasufumi Kinoshita
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko, Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz. Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
(c) 2017, 2021, MariaDB Corporation. (c) 2017, 2022, MariaDB Corporation.
Portions written by Marko Mäkelä. Portions written by Marko Mäkelä.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -3002,10 +3002,21 @@ static bool xtrabackup_copy_logfile() ...@@ -3002,10 +3002,21 @@ static bool xtrabackup_copy_logfile()
recv_sys.offset); recv_sys.offset);
source_offset&= ~block_size_1; source_offset&= ~block_size_1;
size_t size{log_sys.buf_size - recv_sys.len}; size_t size{log_sys.buf_size - recv_sys.len};
if (source_offset + size > log_sys.file_size) if (UNIV_UNLIKELY(source_offset + size > log_sys.file_size))
size= static_cast<size_t>(log_sys.file_size - source_offset); {
ut_ad(size <= log_sys.buf_size); const size_t first{size_t(log_sys.file_size - source_offset)};
log_sys.log.read(source_offset, {log_sys.buf, size}); ut_ad(first <= log_sys.buf_size);
log_sys.log.read(source_offset, {log_sys.buf, first});
size-= first;
if (log_sys.START_OFFSET + size > source_offset)
size= size_t(source_offset - log_sys.START_OFFSET);
if (size)
log_sys.log.read(log_sys.START_OFFSET,
{log_sys.buf + first, size});
size+= first;
}
else
log_sys.log.read(source_offset, {log_sys.buf, size});
recv_sys.len= size; recv_sys.len= size;
} }
......
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