Skip to content

Commit 4a872ae

Browse files
committed
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.
1 parent 9edadc2 commit 4a872ae

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5510,10 +5510,10 @@ xtrabackup_prepare_func(char** argv)
55105510
else {
55115511
xb_process_datadir(".", ".new", prepare_handle_new_files);
55125512
}
5513-
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
5514-
".ren", prepare_handle_ren_files);
55155513
xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".",
55165514
".del", prepare_handle_del_files);
5515+
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
5516+
".ren", prepare_handle_ren_files);
55175517

55185518

55195519
int argc; for (argc = 0; argv[argc]; argc++) {}

mysql-test/suite/mariabackup/drop_table_during_backup.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
CREATE TABLE t1 (i int) ENGINE=INNODB;
22
CREATE TABLE t2 (i int) ENGINE=INNODB;
33
CREATE TABLE t3 (i int) ENGINE=INNODB;
4+
CREATE TABLE t4 (i int) ENGINE=INNODB;
5+
CREATE TABLE t5 (i int) ENGINE=INNODB;
46
# xtrabackup prepare
57
# shutdown server
68
# remove datadir
@@ -11,3 +13,6 @@ DROP TABLE t1;
1113
CREATE TABLE t2(i int);
1214
DROP TABLE t2;
1315
DROP TABLE t3;
16+
CREATE TABLE t4(i int);
17+
DROP TABLE t4;
18+
DROP TABLE t5;

mysql-test/suite/mariabackup/drop_table_during_backup.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
33
CREATE TABLE t1 (i int) ENGINE=INNODB;
44
CREATE TABLE t2 (i int) ENGINE=INNODB;
55
CREATE TABLE t3 (i int) ENGINE=INNODB;
6+
CREATE TABLE t4 (i int) ENGINE=INNODB;
7+
CREATE TABLE t5 (i int) ENGINE=INNODB;
8+
69
--let before_copy_test_t1=DROP TABLE test.t1
710
--let after_copy_test_t2=DROP TABLE test.t2;
11+
# MDEV-18185, drop + rename combination
12+
--let after_copy_test_t5=BEGIN NOT ATOMIC DROP TABLE test.t5; RENAME TABLE test.t4 TO test.t5; END
13+
814
--disable_result_log
915
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events;
1016
--enable_result_log
@@ -21,4 +27,7 @@ DROP TABLE t1;
2127
CREATE TABLE t2(i int);
2228
DROP TABLE t2;
2329
DROP TABLE t3;
30+
CREATE TABLE t4(i int);
31+
DROP TABLE t4;
32+
DROP TABLE t5;
2433
rmdir $targetdir;

0 commit comments

Comments
 (0)