mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
061adae9a2
On Windows systems, occurrences of ERROR_SHARING_VIOLATION due to conflicting share modes between processes accessing the same file can result in CreateFile failures. mysys' my_open() already incorporates a workaround by implementing wait/retry logic on Windows. But this does not help if files are opened using shell redirection like mysqltest traditionally did it, i.e via --echo exec "some text" > output_file In such cases, it is cmd.exe, that opens the output_file, and it won't do any sharing-violation retries. This commit addresses the issue by introducing a new built-in command, 'write_line', in mysqltest. This new command serves as a brief alternative to 'write_file', with a single line output, that also resolves variables like "exec" would. Internally, this command will use my_open(), and therefore retry-on-error logic. Hopefully this will eliminate the very sporadic "can't open file because it is used by another process" error on CI.
100 lines
3.5 KiB
Text
100 lines
3.5 KiB
Text
--source include/have_innodb.inc
|
|
# embedded does not support restart
|
|
-- source include/not_embedded.inc
|
|
-- source include/not_valgrind.inc
|
|
# Avoid CrashReporter popup on Mac
|
|
-- source include/not_crashrep.inc
|
|
-- source filekeys_plugin_exists.inc
|
|
#
|
|
# MDEV-8772: Assertion failure in file ha_innodb.cc line 20027 when importing page compressed and encrypted tablespace using incorrect keys
|
|
#
|
|
|
|
call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded.");
|
|
call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .* for how to resolve the issue.");
|
|
|
|
--let $MYSQLD_TMPDIR = `SELECT @@tmpdir`
|
|
--let $MYSQLD_DATADIR = `SELECT @@datadir`
|
|
--let SEARCH_RANGE = 10000000
|
|
--let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd
|
|
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--shutdown_server
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--write_file $MYSQLTEST_VARDIR/keys1.txt
|
|
1;770A8A65DA156D24EE2A093277530142
|
|
4;770A8A65DA156D24EE2A093277530143
|
|
EOF
|
|
|
|
--write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
set global innodb_compression_algorithm = 1;
|
|
|
|
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(255)) ENGINE=InnoDB PAGE_COMPRESSED=1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
|
|
SHOW WARNINGS;
|
|
SHOW CREATE TABLE t1;
|
|
INSERT INTO t1 VALUES (1,'foobar'),(2,'barfoo');
|
|
let MYSQLD_DATADIR =`SELECT @@datadir`;
|
|
FLUSH TABLE t1 FOR EXPORT;
|
|
--echo # List before copying files
|
|
--list_files $MYSQLD_DATADIR/test
|
|
perl;
|
|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
|
ib_backup_tablespaces("test", "t1");
|
|
EOF
|
|
UNLOCK TABLES;
|
|
|
|
ALTER TABLE t1 DISCARD TABLESPACE;
|
|
|
|
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--shutdown_server
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--write_file $MYSQLTEST_VARDIR/keys2.txt
|
|
1;770A8A65DA156D24EE2A093277530142
|
|
4;770A8A65DA156D24EE2A093277530144
|
|
EOF
|
|
|
|
perl;
|
|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
|
ib_discard_tablespaces("test", "t1");
|
|
ib_restore_tablespaces("test", "t1");
|
|
EOF
|
|
|
|
--write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
--source include/restart_mysqld.inc
|
|
|
|
--error ER_GET_ERRMSG
|
|
ALTER TABLE t1 IMPORT TABLESPACE;
|
|
SHOW CREATE TABLE t1;
|
|
--error ER_TABLESPACE_DISCARDED
|
|
SELECT * FROM t1;
|
|
--sleep 5
|
|
--echo # Tablespaces should be still encrypted
|
|
-- let SEARCH_FILE=$t1_IBD
|
|
--let SEARCH_PATTERN=foobar
|
|
--echo # t1 yes on expecting NOT FOUND
|
|
-- let SEARCH_FILE=$t1_IBD
|
|
-- source include/search_pattern_in_file.inc
|
|
|
|
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--shutdown_server
|
|
--source include/wait_until_disconnected.inc
|
|
--remove_file $MYSQLTEST_VARDIR/keys1.txt
|
|
--write_file $MYSQLTEST_VARDIR/keys1.txt
|
|
1;770A8A65DA156D24EE2A093277530142
|
|
4;770A8A65DA156D24EE2A093277530143
|
|
EOF
|
|
|
|
--write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
DROP TABLE t1;
|
|
|
|
# reset system
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/keys1.txt
|
|
--remove_file $MYSQLTEST_VARDIR/keys2.txt
|