From 4a872ae1e725b8d17f8266a9ca33a2aca4285c00 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 9 Jan 2019 22:28:31 +0100 Subject: [PATCH] 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. --- extra/mariabackup/xtrabackup.cc | 4 ++-- .../suite/mariabackup/drop_table_during_backup.result | 5 +++++ .../suite/mariabackup/drop_table_during_backup.test | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 1b5e28bb257..e0013979901 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -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++) {} diff --git a/mysql-test/suite/mariabackup/drop_table_during_backup.result b/mysql-test/suite/mariabackup/drop_table_during_backup.result index 1472ddbddcf..8a77945e586 100644 --- a/mysql-test/suite/mariabackup/drop_table_during_backup.result +++ b/mysql-test/suite/mariabackup/drop_table_during_backup.result @@ -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; diff --git a/mysql-test/suite/mariabackup/drop_table_during_backup.test b/mysql-test/suite/mariabackup/drop_table_during_backup.test index 02c7710145b..e3a81b77b71 100644 --- a/mysql-test/suite/mariabackup/drop_table_during_backup.test +++ b/mysql-test/suite/mariabackup/drop_table_during_backup.test @@ -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;