mariadb/mysql-test/suite/innodb/t/import_tablespace_race.test
Lorna Luo 0cc1694e9c Make 'move_file' command more reliable in 3 innodb tests
The tests innodb.import_tablespace_race, innodn.restart, and innodb.innodb-wl5522 move
the tablespace file between the data directory and the tmp directory specified by
global environment variables. However this is risky because it's not unusual that the
set tmp directory (often under /tmp) is mounted on another disk partition or device,
and 'move_file' command may fail with "Errcode: 18 'Invalid cross-device link.'"

For innodb.import_tablespace_race and innodb.innodb-wl5522, moving files
across directories is not necessary. Modify the tests so they rename
files under the same directory. For innodb.restart, instead of moving
between datadir and MYSQL_TMPDIR, move the files under MYSQLTEST_VARDIR.

All new code of the whole pull request, including one or several files that
are either new files or modified ones, are contributed under the BSD-new license.
I am contributing on behalf of my employer Amazon Web Services, Inc.
2023-04-03 14:36:11 +02:00

54 lines
1.2 KiB
Text

--source include/have_innodb.inc
--source include/have_sequence.inc
--echo #
--echo # MDEV-29144 ER_TABLE_SCHEMA_MISMATCH or crash on DISCARD/IMPORT
--echo #
CREATE TABLE t (pk int PRIMARY KEY, c varchar(1024))
ENGINE=InnoDB CHARSET latin1;
INSERT INTO t SELECT seq, 'x' FROM seq_1_to_100;
--connect (con1,localhost,root,,test)
--delimiter $
--send
BEGIN NOT ATOMIC
DECLARE a INT DEFAULT 0;
REPEAT
SET a= a+1;
UPDATE t SET c = 'xx' WHERE pk = a;
UNTIL a = 100
END REPEAT;
END
$
--delimiter ;
--connection default
--error 0,ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t NOWAIT ADD INDEX (c);
--connection con1
--reap
--connection default
--let $datadir= `select @@datadir`
FLUSH TABLE t FOR EXPORT;
--let $create= query_get_value(SHOW CREATE TABLE t, Create Table, 1)
--copy_file $datadir/test/t.cfg $datadir/test/t.cfg.sav
--copy_file $datadir/test/t.ibd $datadir/test/t.ibd.sav
UNLOCK TABLES;
DROP TABLE t;
--disable_query_log
eval $create;
--enable_query_log
ALTER TABLE t DISCARD TABLESPACE;
--move_file $datadir/test/t.cfg.sav $datadir/test/t.cfg
--move_file $datadir/test/t.ibd.sav $datadir/test/t.ibd
ALTER TABLE t IMPORT TABLESPACE;
# Cleanup
DROP TABLE t;