284 lines
8.2 KiB
Plaintext
284 lines
8.2 KiB
Plaintext
#
|
|
# This test shows that datafiles can be moved after a crash in such a way
|
|
# that recovery can occur on the datafiles at the new location.
|
|
#
|
|
SET DEFAULT_STORAGE_ENGINE=InnoDB;
|
|
#
|
|
# Create various kinds of tablespaces in both local and remote
|
|
# locations and start populating them in a transaction.
|
|
#
|
|
CREATE TABLESPACE ts1 ADD DATAFILE 'tablespace1.ibd' ENGINE=InnoDB;
|
|
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;
|
|
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);
|
|
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
|
|
Space_Name Space_Type Page_Size Zip_Size Formats_Permitted Path
|
|
ts1 General DEFAULT 0 Any MYSQLD_DATADIR/tablespace1.ibd
|
|
ts2 General DEFAULT 0 Any MYSQL_TMP_DIR/tablespace2.ibd
|
|
test/t3 Single DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t3.ibd
|
|
test/t4 Single DEFAULT 0 Dynamic MYSQL_TMP_DIR/test/t4.ibd
|
|
=== information_schema.files ===
|
|
Space_Name File_Type Engine Status Tablespace_Name Path
|
|
ts1 TABLESPACE InnoDB NORMAL ts1 MYSQLD_DATADIR/tablespace1.ibd
|
|
ts2 TABLESPACE InnoDB NORMAL ts2 MYSQL_TMP_DIR/tablespace2.ibd
|
|
test/t3 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t3.ibd
|
|
test/t4 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQL_TMP_DIR/test/t4.ibd
|
|
t4.ibd
|
|
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);
|
|
#
|
|
# Kill the server
|
|
# Copy the datafiles so that they can be found
|
|
# in both default and remote locations.
|
|
# Restart mysqld and display which datafiles were recovered.
|
|
# restart
|
|
# Default locations should be recovered.
|
|
#
|
|
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
|
|
Space_Name Space_Type Page_Size Zip_Size Formats_Permitted Path
|
|
ts1 General DEFAULT 0 Any MYSQLD_DATADIR/tablespace1.ibd
|
|
ts2 General DEFAULT 0 Any MYSQLD_DATADIR/tablespace2.ibd
|
|
test/t3 Single DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t3.ibd
|
|
test/t4 Single DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t4.ibd
|
|
=== information_schema.files ===
|
|
Space_Name File_Type Engine Status Tablespace_Name Path
|
|
ts1 TABLESPACE InnoDB NORMAL ts1 MYSQLD_DATADIR/tablespace1.ibd
|
|
ts2 TABLESPACE InnoDB NORMAL ts2 MYSQLD_DATADIR/tablespace2.ibd
|
|
test/t3 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t3.ibd
|
|
test/t4 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t4.ibd
|
|
select * from t1a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t2a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t3;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t4;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
SHOW CREATE TABLE t1a;
|
|
Table Create Table
|
|
t1a CREATE TABLE `t1a` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `ts1` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t2a;
|
|
Table Create Table
|
|
t2a CREATE TABLE `t2a` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `ts2` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t3;
|
|
Table Create Table
|
|
t3 CREATE TABLE `t3` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t4;
|
|
Table Create Table
|
|
t4 CREATE TABLE `t4` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
#
|
|
# Start a transaction to each table again.
|
|
#
|
|
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);
|
|
#
|
|
# Kill the server
|
|
# Changes were made to the files in the default locations and the
|
|
# SYS_DATAFILES.PATH was updated to show the default location.
|
|
# Delete the older remote files and move the default files to the
|
|
# remote locations.
|
|
# Restart mysqld and show that the remote files were opened and recovered.
|
|
# restart
|
|
#
|
|
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
|
|
Space_Name Space_Type Page_Size Zip_Size Formats_Permitted Path
|
|
ts1 General DEFAULT 0 Any MYSQL_TMP_DIR/tablespace1.ibd
|
|
ts2 General DEFAULT 0 Any MYSQL_TMP_DIR/tablespace2.ibd
|
|
test/t3 Single DEFAULT 0 Dynamic MYSQL_TMP_DIR/test/t3.ibd
|
|
test/t4 Single DEFAULT 0 Dynamic MYSQL_TMP_DIR/test/t4.ibd
|
|
=== information_schema.files ===
|
|
Space_Name File_Type Engine Status Tablespace_Name Path
|
|
ts1 TABLESPACE InnoDB NORMAL ts1 MYSQL_TMP_DIR/tablespace1.ibd
|
|
ts2 TABLESPACE InnoDB NORMAL ts2 MYSQL_TMP_DIR/tablespace2.ibd
|
|
test/t3 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQL_TMP_DIR/test/t3.ibd
|
|
test/t4 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQL_TMP_DIR/test/t4.ibd
|
|
select * from t1a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t2a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t3;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t4;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
SHOW CREATE TABLE t1a;
|
|
Table Create Table
|
|
t1a CREATE TABLE `t1a` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `ts1` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t2a;
|
|
Table Create Table
|
|
t2a CREATE TABLE `t2a` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `ts2` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t3;
|
|
Table Create Table
|
|
t3 CREATE TABLE `t3` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t4;
|
|
Table Create Table
|
|
t4 CREATE TABLE `t4` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TMP_DIR/'
|
|
#
|
|
# Start a transaction to each table again.
|
|
#
|
|
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);
|
|
#
|
|
# Kill the server
|
|
# Mess up a general tablespace ISL file so that it points to the wrong file.
|
|
# Recovery will fail. Check the error message.
|
|
# Mess up a file-per-table tablespace ISL file so that it points to the wrong file.
|
|
# Recovery will fail. Check the error message.
|
|
# Delete the ISL files and move all remote files to default locations
|
|
# Restart mysqld and display which datafiles were recovered.
|
|
# restart
|
|
# It should be the default datafiles
|
|
# The two previous attempts to recover should not cause a problem
|
|
#
|
|
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
|
|
Space_Name Space_Type Page_Size Zip_Size Formats_Permitted Path
|
|
ts1 General DEFAULT 0 Any MYSQLD_DATADIR/tablespace1.ibd
|
|
ts2 General DEFAULT 0 Any MYSQLD_DATADIR/tablespace2.ibd
|
|
test/t3 Single DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t3.ibd
|
|
test/t4 Single DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t4.ibd
|
|
=== information_schema.files ===
|
|
Space_Name File_Type Engine Status Tablespace_Name Path
|
|
ts1 TABLESPACE InnoDB NORMAL ts1 MYSQLD_DATADIR/tablespace1.ibd
|
|
ts2 TABLESPACE InnoDB NORMAL ts2 MYSQLD_DATADIR/tablespace2.ibd
|
|
test/t3 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t3.ibd
|
|
test/t4 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t4.ibd
|
|
select * from t1a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t2a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t3;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select * from t4;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
SHOW CREATE TABLE t1a;
|
|
Table Create Table
|
|
t1a CREATE TABLE `t1a` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `ts1` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t2a;
|
|
Table Create Table
|
|
t2a CREATE TABLE `t2a` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `ts2` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t3;
|
|
Table Create Table
|
|
t3 CREATE TABLE `t3` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE t4;
|
|
Table Create Table
|
|
t4 CREATE TABLE `t4` (
|
|
`a` int(11) DEFAULT NULL
|
|
) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
#
|
|
# Cleanup
|
|
#
|
|
DROP TABLE t1a;
|
|
DROP TABLE t1b;
|
|
DROP TABLE t2a;
|
|
DROP TABLE t2b;
|
|
DROP TABLE t3;
|
|
DROP TABLE t4;
|
|
DROP TABLESPACE ts1;
|
|
DROP TABLESPACE ts2;
|