MDEV-18185 - mariabackup - fix specific case of table rename handing in prepare.

If, during backup
1) Innodb table is dropped (after being copied to backup) and then
2) Before backup finished, another Innodb table is renamed, and new name
is the name of the dropped table in 1)

then, --prepare fails with assertion, as DDL fixup code in prepare
did not handle this specific case.

The fix is to process drops before renames, in prepare DDL-"redo" phase.
This commit is contained in:
Vladislav Vaintroub 2019-01-09 22:28:31 +01:00
parent 9edadc29b1
commit 4a872ae1e7
3 changed files with 16 additions and 2 deletions

View file

@ -5510,10 +5510,10 @@ xtrabackup_prepare_func(char** argv)
else {
xb_process_datadir(".", ".new", prepare_handle_new_files);
}
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
".ren", prepare_handle_ren_files);
xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".",
".del", prepare_handle_del_files);
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
".ren", prepare_handle_ren_files);
int argc; for (argc = 0; argv[argc]; argc++) {}

View file

@ -1,6 +1,8 @@
CREATE TABLE t1 (i int) ENGINE=INNODB;
CREATE TABLE t2 (i int) ENGINE=INNODB;
CREATE TABLE t3 (i int) ENGINE=INNODB;
CREATE TABLE t4 (i int) ENGINE=INNODB;
CREATE TABLE t5 (i int) ENGINE=INNODB;
# xtrabackup prepare
# shutdown server
# remove datadir
@ -11,3 +13,6 @@ DROP TABLE t1;
CREATE TABLE t2(i int);
DROP TABLE t2;
DROP TABLE t3;
CREATE TABLE t4(i int);
DROP TABLE t4;
DROP TABLE t5;

View file

@ -3,8 +3,14 @@ let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
CREATE TABLE t1 (i int) ENGINE=INNODB;
CREATE TABLE t2 (i int) ENGINE=INNODB;
CREATE TABLE t3 (i int) ENGINE=INNODB;
CREATE TABLE t4 (i int) ENGINE=INNODB;
CREATE TABLE t5 (i int) ENGINE=INNODB;
--let before_copy_test_t1=DROP TABLE test.t1
--let after_copy_test_t2=DROP TABLE test.t2;
# MDEV-18185, drop + rename combination
--let after_copy_test_t5=BEGIN NOT ATOMIC DROP TABLE test.t5; RENAME TABLE test.t4 TO test.t5; END
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events;
--enable_result_log
@ -21,4 +27,7 @@ DROP TABLE t1;
CREATE TABLE t2(i int);
DROP TABLE t2;
DROP TABLE t3;
CREATE TABLE t4(i int);
DROP TABLE t4;
DROP TABLE t5;
rmdir $targetdir;