224 lines
7.6 KiB
Plaintext
224 lines
7.6 KiB
Plaintext
--echo #
|
|
--echo # This test shows that datafiles can be moved after a crash in such a way
|
|
--echo # that recovery can occur on the datafiles at the new location.
|
|
--echo #
|
|
|
|
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
# Restarting and killing mysqld is not supported in embedded
|
|
--source include/not_embedded.inc
|
|
--source include/not_valgrind.inc
|
|
|
|
SET DEFAULT_STORAGE_ENGINE=InnoDB;
|
|
|
|
# Set these up for show_i_s_tablespaces.inc
|
|
LET $MYSQLD_DATADIR = `select @@datadir`;
|
|
LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
|
|
|
|
--echo #
|
|
--echo # Create various kinds of tablespaces in both local and remote
|
|
--echo # locations and start populating them in a transaction.
|
|
--echo #
|
|
CREATE TABLESPACE ts1 ADD DATAFILE 'tablespace1.ibd' ENGINE=InnoDB;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
eval CREATE TABLESPACE ts2 ADD DATAFILE '$MYSQL_TMP_DIR/tablespace2.ibd' ENGINE=InnoDB;
|
|
CREATE TABLE t1a (a int) TABLESPACE=ts1;
|
|
CREATE TABLE t1b (a int) TABLESPACE=ts1;
|
|
CREATE TABLE t2a (a int) TABLESPACE=ts2;
|
|
CREATE TABLE t2b (a int) TABLESPACE=ts2;
|
|
CREATE TABLE t3 (a int) TABLESPACE=innodb_file_per_table;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
eval CREATE TABLE t4 (a int) TABLESPACE=innodb_file_per_table DATA DIRECTORY='$MYSQL_TMP_DIR';
|
|
INSERT INTO t1a VALUES (1),(2),(3),(4),(5);
|
|
INSERT INTO t1b VALUES (1),(2),(3),(4),(5);
|
|
INSERT INTO t2a VALUES (1),(2),(3),(4),(5);
|
|
INSERT INTO t2b VALUES (1),(2),(3),(4),(5);
|
|
INSERT INTO t3 VALUES (1),(2),(3),(4),(5);
|
|
INSERT INTO t4 VALUES (1),(2),(3),(4),(5);
|
|
--source suite/innodb/include/show_i_s_tablespaces.inc
|
|
--list_files $MYSQL_TMP_DIR/test
|
|
|
|
START TRANSACTION;
|
|
INSERT INTO t1a VALUES (6);
|
|
INSERT INTO t1b VALUES (6);
|
|
INSERT INTO t2a VALUES (6);
|
|
INSERT INTO t2b VALUES (6);
|
|
INSERT INTO t3 VALUES (6);
|
|
INSERT INTO t4 VALUES (6);
|
|
|
|
--echo #
|
|
--source include/kill_mysqld.inc
|
|
|
|
--echo # Copy the datafiles so that they can be found
|
|
--echo # in both default and remote locations.
|
|
--copy_file $MYSQLD_DATADIR/tablespace1.ibd $MYSQL_TMP_DIR/tablespace1.ibd
|
|
--exec echo $MYSQL_TMP_DIR/tablespace1.ibd > $MYSQLD_DATADIR/tablespace1.isl
|
|
--copy_file $MYSQL_TMP_DIR/tablespace2.ibd $MYSQLD_DATADIR/tablespace2.ibd
|
|
--copy_file $MYSQLD_DATADIR/test/t3.ibd $MYSQL_TMP_DIR/test/t3.ibd
|
|
--exec echo $MYSQL_TMP_DIR/test/t3.ibd > $MYSQLD_DATADIR/test/t3.isl
|
|
--copy_file $MYSQL_TMP_DIR/test/t4.ibd $MYSQLD_DATADIR/test/t4.ibd
|
|
|
|
--echo # Restart mysqld and display which datafiles were recovered.
|
|
--source include/start_mysqld.inc
|
|
|
|
--echo # Default locations should be recovered.
|
|
--echo #
|
|
|
|
--source suite/innodb/include/show_i_s_tablespaces.inc
|
|
select * from t1a;
|
|
select * from t2a;
|
|
select * from t3;
|
|
select * from t4;
|
|
SHOW CREATE TABLE t1a;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
SHOW CREATE TABLE t2a;
|
|
SHOW CREATE TABLE t3;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
SHOW CREATE TABLE t4;
|
|
|
|
--echo #
|
|
--echo # Start a transaction to each table again.
|
|
--echo #
|
|
|
|
START TRANSACTION;
|
|
INSERT INTO t1a VALUES (6);
|
|
INSERT INTO t1b VALUES (6);
|
|
INSERT INTO t2a VALUES (6);
|
|
INSERT INTO t2b VALUES (6);
|
|
INSERT INTO t3 VALUES (6);
|
|
INSERT INTO t4 VALUES (6);
|
|
|
|
--echo #
|
|
--source include/kill_mysqld.inc
|
|
|
|
--echo # Changes were made to the files in the default locations and the
|
|
--echo # SYS_DATAFILES.PATH was updated to show the default location.
|
|
--echo # Delete the older remote files and move the default files to the
|
|
--echo # remote locations.
|
|
--remove_file $MYSQL_TMP_DIR/tablespace1.ibd
|
|
--remove_file $MYSQL_TMP_DIR/tablespace2.ibd
|
|
--remove_file $MYSQL_TMP_DIR/test/t3.ibd
|
|
--remove_file $MYSQL_TMP_DIR/test/t4.ibd
|
|
--move_file $MYSQLD_DATADIR/tablespace1.ibd $MYSQL_TMP_DIR/tablespace1.ibd
|
|
--move_file $MYSQLD_DATADIR/tablespace2.ibd $MYSQL_TMP_DIR/tablespace2.ibd
|
|
--move_file $MYSQLD_DATADIR/test/t3.ibd $MYSQL_TMP_DIR/test/t3.ibd
|
|
--move_file $MYSQLD_DATADIR/test/t4.ibd $MYSQL_TMP_DIR/test/t4.ibd
|
|
--exec echo $MYSQL_TMP_DIR/tablespace1.ibd > $MYSQLD_DATADIR/tablespace1.isl
|
|
--exec echo $MYSQL_TMP_DIR/tablespace2.ibd > $MYSQLD_DATADIR/tablespace2.isl
|
|
--exec echo $MYSQL_TMP_DIR/test/t3.ibd > $MYSQLD_DATADIR/tablespace3.isl
|
|
--exec echo $MYSQL_TMP_DIR/test/t4.ibd > $MYSQLD_DATADIR/tablespace4.isl
|
|
|
|
--echo # Restart mysqld and show that the remote files were opened and recovered.
|
|
--source include/start_mysqld.inc
|
|
--echo #
|
|
|
|
|
|
--source suite/innodb/include/show_i_s_tablespaces.inc
|
|
select * from t1a;
|
|
select * from t2a;
|
|
select * from t3;
|
|
select * from t4;
|
|
SHOW CREATE TABLE t1a;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
SHOW CREATE TABLE t2a;
|
|
SHOW CREATE TABLE t3;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
SHOW CREATE TABLE t4;
|
|
|
|
--echo #
|
|
--echo # Start a transaction to each table again.
|
|
--echo #
|
|
|
|
START TRANSACTION;
|
|
INSERT INTO t1a VALUES (6);
|
|
INSERT INTO t1b VALUES (6);
|
|
INSERT INTO t2a VALUES (6);
|
|
INSERT INTO t2b VALUES (6);
|
|
INSERT INTO t3 VALUES (6);
|
|
INSERT INTO t4 VALUES (6);
|
|
|
|
--echo #
|
|
--source include/kill_mysqld.inc
|
|
|
|
--echo # Mess up a general tablespace ISL file so that it points to the wrong file.
|
|
--echo # Recovery will fail. Check the error message.
|
|
|
|
--exec echo $MYSQL_TMP_DIR/bad/tablespace1.ibd > $MYSQLD_DATADIR/tablespace1.isl
|
|
|
|
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err;
|
|
--error 3,42
|
|
--exec $MYSQLD_CMD --core-file --console > $SEARCH_FILE 2>&1;
|
|
|
|
let SEARCH_PATTERN= \[ERROR\] InnoDB: ISL file '.*tablespace1.isl' was found but the linked file '.*tablespace1.ibd' could not be opened or is not correct;
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace .* was not found at .*tablespace1.ibd;
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot continue operation;
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
--remove_file $SEARCH_FILE
|
|
|
|
--echo # Mess up a file-per-table tablespace ISL file so that it points to the wrong file.
|
|
--echo # Recovery will fail. Check the error message.
|
|
|
|
--exec echo $MYSQL_TMP_DIR/tablespace1.ibd > $MYSQLD_DATADIR/tablespace1.isl
|
|
--exec echo $MYSQL_TMP_DIR/bad/t3.ibd > $MYSQLD_DATADIR/test/t3.isl
|
|
|
|
--error 3,42
|
|
--exec $MYSQLD_CMD --core-file --console > $SEARCH_FILE 2>&1;
|
|
|
|
let SEARCH_PATTERN= \[ERROR\] InnoDB: ISL file '.*t3.isl' was found but the linked file '.*t3.ibd' could not be opened or is not correct;
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace .* was not found at .*t3.ibd;
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot continue operation;
|
|
--source include/search_pattern_in_file.inc
|
|
|
|
--remove_file $SEARCH_FILE
|
|
|
|
--echo # Delete the ISL files and move all remote files to default locations
|
|
--remove_file $MYSQLD_DATADIR/tablespace1.isl
|
|
--remove_file $MYSQLD_DATADIR/tablespace2.isl
|
|
--remove_file $MYSQLD_DATADIR/test/t3.isl
|
|
--remove_file $MYSQLD_DATADIR/test/t4.isl
|
|
--move_file $MYSQL_TMP_DIR/tablespace1.ibd $MYSQLD_DATADIR/tablespace1.ibd
|
|
--move_file $MYSQL_TMP_DIR/tablespace2.ibd $MYSQLD_DATADIR/tablespace2.ibd
|
|
--move_file $MYSQL_TMP_DIR/test/t3.ibd $MYSQLD_DATADIR/test/t3.ibd
|
|
--move_file $MYSQL_TMP_DIR/test/t4.ibd $MYSQLD_DATADIR/test/t4.ibd
|
|
|
|
--echo # Restart mysqld and display which datafiles were recovered.
|
|
--source include/start_mysqld.inc
|
|
|
|
--echo # It should be the default datafiles
|
|
--echo # The two previous attempts to recover should not cause a problem
|
|
--echo #
|
|
|
|
--source suite/innodb/include/show_i_s_tablespaces.inc
|
|
select * from t1a;
|
|
select * from t2a;
|
|
select * from t3;
|
|
select * from t4;
|
|
SHOW CREATE TABLE t1a;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
SHOW CREATE TABLE t2a;
|
|
SHOW CREATE TABLE t3;
|
|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
|
SHOW CREATE TABLE t4;
|
|
|
|
--echo #
|
|
--echo # Cleanup
|
|
--echo #
|
|
DROP TABLE t1a;
|
|
DROP TABLE t1b;
|
|
DROP TABLE t2a;
|
|
DROP TABLE t2b;
|
|
DROP TABLE t3;
|
|
DROP TABLE t4;
|
|
DROP TABLESPACE ts1;
|
|
DROP TABLESPACE ts2;
|
|
--rmdir $MYSQL_TMP_DIR/test
|