Commit 7331c661 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent 4a872ae1
...@@ -5503,6 +5503,14 @@ xtrabackup_prepare_func(char** argv) ...@@ -5503,6 +5503,14 @@ xtrabackup_prepare_func(char** argv)
fil_path_to_mysql_datadir = "."; fil_path_to_mysql_datadir = ".";
/* Fix DDL for prepare. Process .del,.ren, and .new files.
The order in which files are processed, is important
(see MDEV-18185, MDEV-18201)
*/
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);
if (xtrabackup_incremental_dir) { if (xtrabackup_incremental_dir) {
xb_process_datadir(xtrabackup_incremental_dir, ".new.meta", prepare_handle_new_files); xb_process_datadir(xtrabackup_incremental_dir, ".new.meta", prepare_handle_new_files);
xb_process_datadir(xtrabackup_incremental_dir, ".new.delta", prepare_handle_new_files); xb_process_datadir(xtrabackup_incremental_dir, ".new.delta", prepare_handle_new_files);
...@@ -5510,11 +5518,6 @@ xtrabackup_prepare_func(char** argv) ...@@ -5510,11 +5518,6 @@ xtrabackup_prepare_func(char** argv)
else { else {
xb_process_datadir(".", ".new", prepare_handle_new_files); xb_process_datadir(".", ".new", prepare_handle_new_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++) {} int argc; for (argc = 0; argv[argc]; argc++) {}
encryption_plugin_prepare_init(argc, argv); encryption_plugin_prepare_init(argc, argv);
......
...@@ -4,6 +4,8 @@ CREATE TABLE t2(i int) ENGINE INNODB; ...@@ -4,6 +4,8 @@ CREATE TABLE t2(i int) ENGINE INNODB;
INSERT INTO t2 values(2); INSERT INTO t2 values(2);
CREATE TABLE t3(i int) ENGINE INNODB; CREATE TABLE t3(i int) ENGINE INNODB;
CREATE TABLE t4(i int) ENGINE INNODB; CREATE TABLE t4(i int) ENGINE INNODB;
CREATE TABLE t5(i int) ENGINE INNODB;
INSERT INTO t5 VALUES(5);
CREATE TABLE a(a int) ENGINE INNODB; CREATE TABLE a(a int) ENGINE INNODB;
INSERT INTO a values(1); INSERT INTO a values(1);
CREATE TABLE b(b CHAR(1)) ENGINE INNODB; CREATE TABLE b(b CHAR(1)) ENGINE INNODB;
...@@ -51,3 +53,10 @@ SELECT * FROM b1; ...@@ -51,3 +53,10 @@ SELECT * FROM b1;
a1 a1
1 1
DROP TABLE a,b,a1,b1; DROP TABLE a,b,a1,b1;
SELECT * from t5;
i
DROP TABLE t5;
SELECT * from t6;
i
5
DROP TABLE t6;
...@@ -10,6 +10,8 @@ INSERT INTO t2 values(2); ...@@ -10,6 +10,8 @@ INSERT INTO t2 values(2);
CREATE TABLE t3(i int) ENGINE INNODB; CREATE TABLE t3(i int) ENGINE INNODB;
CREATE TABLE t4(i int) ENGINE INNODB; CREATE TABLE t4(i int) ENGINE INNODB;
CREATE TABLE t5(i int) ENGINE INNODB;
INSERT INTO t5 VALUES(5);
CREATE TABLE a(a int) ENGINE INNODB; CREATE TABLE a(a int) ENGINE INNODB;
INSERT INTO a values(1); INSERT INTO a values(1);
...@@ -28,6 +30,7 @@ INSERT INTO b1 VALUES('b1'); ...@@ -28,6 +30,7 @@ INSERT INTO b1 VALUES('b1');
--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 --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
--let before_copy_test_t4=RENAME TABLE test.t4 TO test.t4_tmp --let before_copy_test_t4=RENAME TABLE test.t4 TO test.t4_tmp
--let after_copy_test_t4=RENAME TABLE test.t4_tmp TO test.t4 --let after_copy_test_t4=RENAME TABLE test.t4_tmp TO test.t4
--let after_copy_test_t5=BEGIN NOT ATOMIC RENAME TABLE test.t5 TO test.t6; CREATE TABLE test.t5(i int) ENGINE INNODB; END
# Test circular renames # Test circular renames
--let before_copy_test_b=RENAME TABLE test.a to test.tmp, test.b to test.a, test.tmp to test.b --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; ...@@ -81,6 +84,10 @@ SELECT * FROM a1;
SELECT * FROM b1; SELECT * FROM b1;
DROP TABLE a,b,a1,b1; DROP TABLE a,b,a1,b1;
SELECT * from t5;
DROP TABLE t5;
SELECT * from t6;
DROP TABLE t6;
rmdir $targetdir; rmdir $targetdir;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment