MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken
When "mariabackup --target-dir=$basedir --incremental-dir=$incremental_dir" is running and is moving a new table file (e.g. `db1/t1.new`) from the incremental directory to the base directory, it needs to verify that the base backup database directory (e.g. `$basedir/db1`) really exists (or create it otherwise). The table `db1/t1` can come from a new database `db1` which was created during the base mariabackup execution time. In such case the directory `db1` exists only in the incremental directory, but does not exist in the base directory.
This commit is contained in:
parent
f354e457e1
commit
680ca15269
@ -5441,11 +5441,23 @@ static ibool prepare_handle_new_files(const char *data_home_dir,
|
||||
const char *file_name, void *arg)
|
||||
{
|
||||
const char *dest_dir = static_cast<const char *>(arg);
|
||||
std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/' + file_name;
|
||||
std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/';
|
||||
/* Copy "*.new" files from incremental to base dir for incremental backup */
|
||||
std::string dest_path=
|
||||
dest_dir ? std::string(dest_dir) + '/' + std::string(db_name) +
|
||||
'/' + file_name : src_path;
|
||||
'/' : src_path;
|
||||
|
||||
/*
|
||||
A CREATE DATABASE could have happened during the base mariabackup run.
|
||||
In case if the current table file (e.g. `t1.new`) is from such
|
||||
a new database, the database directory may not exist yet in
|
||||
the base backup directory. Let's make sure to check if the directory
|
||||
exists (and create if needed).
|
||||
*/
|
||||
if (!directory_exists(dest_path.c_str(), true/*create if not exists*/))
|
||||
return FALSE;
|
||||
src_path+= file_name;
|
||||
dest_path+= file_name;
|
||||
|
||||
size_t index = dest_path.find(".new");
|
||||
DBUG_ASSERT(index != std::string::npos);
|
||||
|
@ -0,0 +1,24 @@
|
||||
call mtr.add_suppression("InnoDB: New log files created");
|
||||
#
|
||||
# Start of 10.2 tests
|
||||
#
|
||||
#
|
||||
# MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken
|
||||
#
|
||||
CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB;
|
||||
# Prepare full backup, apply incremental one
|
||||
# shutdown server
|
||||
# remove datadir
|
||||
# xtrabackup move back
|
||||
# restart server
|
||||
SELECT COUNT(*) FROM test.t1;
|
||||
COUNT(*)
|
||||
0
|
||||
SELECT COUNT(*) FROM test1.t1;
|
||||
COUNT(*)
|
||||
10000
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE test1;
|
||||
#
|
||||
# End of 10.2 tests
|
||||
#
|
@ -0,0 +1,47 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
|
||||
call mtr.add_suppression("InnoDB: New log files created");
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.2 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken
|
||||
--echo #
|
||||
|
||||
--let $basedir=$MYSQLTEST_VARDIR/tmp/backup
|
||||
--let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1
|
||||
|
||||
CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB;
|
||||
|
||||
--disable_result_log
|
||||
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir
|
||||
--enable_result_log
|
||||
|
||||
--let after_load_tablespaces=BEGIN NOT ATOMIC CREATE DATABASE test1; CREATE TABLE test1.t1 ENGINE=INNODB SELECT UUID() from test.seq_1_to_10000; END
|
||||
|
||||
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code
|
||||
--let after_load_tablespaces=
|
||||
--disable_result_log
|
||||
--echo # Prepare full backup, apply incremental one
|
||||
--exec $XTRABACKUP --apply-log-only --prepare --target-dir=$basedir
|
||||
--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir
|
||||
--enable_result_log
|
||||
|
||||
--let $targetdir=$basedir
|
||||
--source include/restart_and_restore.inc
|
||||
--enable_result_log
|
||||
|
||||
SELECT COUNT(*) FROM test.t1;
|
||||
SELECT COUNT(*) FROM test1.t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE test1;
|
||||
--rmdir $basedir
|
||||
--rmdir $incremental_dir
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.2 tests
|
||||
--echo #
|
Loading…
x
Reference in New Issue
Block a user