Skip to content

Commit 7331c66

Browse files
committed
MDEV-18201 : mariabackup- fix processing of rename/create sequence in prepare
Fix one more bug in "DDL redo" phase in prepare If table was renamed, and then new table was created with the old name, prepare can be confused, and .ibd can end up with wrong name. Fix the order of how DDL fixup is applied , once again - ".new" files should be processed after renames.
1 parent 4a872ae commit 7331c66

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5503,18 +5503,21 @@ xtrabackup_prepare_func(char** argv)
55035503

55045504
fil_path_to_mysql_datadir = ".";
55055505

5506+
/* Fix DDL for prepare. Process .del,.ren, and .new files.
5507+
The order in which files are processed, is important
5508+
(see MDEV-18185, MDEV-18201)
5509+
*/
5510+
xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".",
5511+
".del", prepare_handle_del_files);
5512+
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
5513+
".ren", prepare_handle_ren_files);
55065514
if (xtrabackup_incremental_dir) {
55075515
xb_process_datadir(xtrabackup_incremental_dir, ".new.meta", prepare_handle_new_files);
55085516
xb_process_datadir(xtrabackup_incremental_dir, ".new.delta", prepare_handle_new_files);
55095517
}
55105518
else {
55115519
xb_process_datadir(".", ".new", prepare_handle_new_files);
55125520
}
5513-
xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".",
5514-
".del", prepare_handle_del_files);
5515-
xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".",
5516-
".ren", prepare_handle_ren_files);
5517-
55185521

55195522
int argc; for (argc = 0; argv[argc]; argc++) {}
55205523
encryption_plugin_prepare_init(argc, argv);

mysql-test/suite/mariabackup/rename_during_backup.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CREATE TABLE t2(i int) ENGINE INNODB;
44
INSERT INTO t2 values(2);
55
CREATE TABLE t3(i int) ENGINE INNODB;
66
CREATE TABLE t4(i int) ENGINE INNODB;
7+
CREATE TABLE t5(i int) ENGINE INNODB;
8+
INSERT INTO t5 VALUES(5);
79
CREATE TABLE a(a int) ENGINE INNODB;
810
INSERT INTO a values(1);
911
CREATE TABLE b(b CHAR(1)) ENGINE INNODB;
@@ -51,3 +53,10 @@ SELECT * FROM b1;
5153
a1
5254
1
5355
DROP TABLE a,b,a1,b1;
56+
SELECT * from t5;
57+
i
58+
DROP TABLE t5;
59+
SELECT * from t6;
60+
i
61+
5
62+
DROP TABLE t6;

mysql-test/suite/mariabackup/rename_during_backup.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ INSERT INTO t2 values(2);
1010

1111
CREATE TABLE t3(i int) ENGINE INNODB;
1212
CREATE TABLE t4(i int) ENGINE INNODB;
13+
CREATE TABLE t5(i int) ENGINE INNODB;
14+
INSERT INTO t5 VALUES(5);
1315

1416
CREATE TABLE a(a int) ENGINE INNODB;
1517
INSERT INTO a values(1);
@@ -28,6 +30,7 @@ INSERT INTO b1 VALUES('b1');
2830
--let after_copy_test_t3=BEGIN NOT ATOMIC RENAME TABLE test.t3 TO test.t3_tmp; INSERT INTO test.t3_tmp VALUES(3); RENAME TABLE test.t3_tmp TO test.t3; END
2931
--let before_copy_test_t4=RENAME TABLE test.t4 TO test.t4_tmp
3032
--let after_copy_test_t4=RENAME TABLE test.t4_tmp TO test.t4
33+
--let after_copy_test_t5=BEGIN NOT ATOMIC RENAME TABLE test.t5 TO test.t6; CREATE TABLE test.t5(i int) ENGINE INNODB; END
3134

3235
# Test circular renames
3336
--let before_copy_test_b=RENAME TABLE test.a to test.tmp, test.b to test.a, test.tmp to test.b
@@ -81,6 +84,10 @@ SELECT * FROM a1;
8184
SELECT * FROM b1;
8285

8386
DROP TABLE a,b,a1,b1;
87+
SELECT * from t5;
88+
DROP TABLE t5;
89+
SELECT * from t6;
90+
DROP TABLE t6;
8491
rmdir $targetdir;
8592

8693

0 commit comments

Comments
 (0)