mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-18733 MariaDB slow start after crash recovery
If InnoDB crash recovery was needed, the InnoDB function srv_start() would invoke extra validation, reading something from every InnoDB data file. This should be unnecessary now that MDEV-14717 made RENAME operations crash-safe inside InnoDB (which can be disabled in MariaDB 10.2 by setting innodb_safe_truncate=OFF). dict_check_sys_tables(): Skip tables that would be dropped by row_mysql_drop_garbage_tables(). Perform extra validation only if innodb_safe_truncate=OFF, innodb_force_recovery=0 and crash recovery was needed. dict_load_table_one(): Validate the root page of the table. In this way, we can deny access to corrupted or mismatching tables not only after crash recovery, but also after a clean shutdown.
This commit is contained in:
@@ -13,6 +13,7 @@ call mtr.add_suppression("Plugin 'file_key_management' registration.*failed");
|
||||
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\.");
|
||||
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
|
||||
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t1.ibd looks corrupted; key_version=1");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted");
|
||||
call mtr.add_suppression("File '.*mysql-test.std_data.keysbad3\\.txt' not found");
|
||||
|
||||
--echo # Start server with keys2.txt
|
||||
@@ -39,7 +40,7 @@ SELECT * FROM t1;
|
||||
-- source include/restart_mysqld.inc
|
||||
|
||||
--disable_warnings
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t1;
|
||||
--enable_warnings
|
||||
|
||||
@@ -70,36 +71,35 @@ INSERT INTO t2 VALUES ('foobar',1,2);
|
||||
-- source include/restart_mysqld.inc
|
||||
|
||||
--disable_warnings
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t2;
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t2 where id = 1;
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t2 where b = 1;
|
||||
|
||||
--replace_regex /tablespace [0-9]*/tablespace /
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
INSERT INTO t2 VALUES ('tmp',3,3);
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
DELETE FROM t2 where b = 3;
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
DELETE FROM t2 where id = 3;
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
UPDATE t2 set b = b +1;
|
||||
|
||||
OPTIMIZE TABLE t2;
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
ALTER TABLE t2 ADD COLUMN d INT;
|
||||
|
||||
ANALYZE TABLE t2;
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
TRUNCATE TABLE t2;
|
||||
|
||||
DROP TABLE t2;
|
||||
|
@@ -13,6 +13,7 @@ call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]
|
||||
# Suppression for builds where file_key_management plugin is linked statically
|
||||
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
|
||||
call mtr.add_suppression("InnoDB: Tablespace for table \`test\`.\`t1\` is set as discarded\\.");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
|
||||
|
||||
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
|
||||
--source include/restart_mysqld.inc
|
||||
@@ -26,11 +27,11 @@ INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
|
||||
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t1;
|
||||
--replace_regex /(tablespace|key_id) [1-9][0-9]*/\1 /
|
||||
SHOW WARNINGS;
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
ALTER TABLE t1 ENGINE=InnoDB;
|
||||
--replace_regex /(tablespace|key_id) [1-9][0-9]*/\1 /
|
||||
SHOW WARNINGS;
|
||||
@@ -57,8 +58,7 @@ UNLOCK TABLES;
|
||||
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
# Discard should pass even with incorrect keys
|
||||
--replace_regex /(tablespace|key_id) [1-9][0-9]*/\1 /
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
ALTER TABLE t1 DISCARD TABLESPACE;
|
||||
|
||||
perl;
|
||||
@@ -71,19 +71,23 @@ EOF
|
||||
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
ALTER TABLE t1 DISCARD TABLESPACE;
|
||||
|
||||
perl;
|
||||
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
||||
ib_discard_tablespaces("test", "t1");
|
||||
ib_restore_tablespaces("test", "t1");
|
||||
EOF
|
||||
|
||||
ALTER TABLE t1 IMPORT TABLESPACE;
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--let $restart_parameters= --innodb-encrypt-tables --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
# Rename table should pass even with incorrect keys
|
||||
--error ER_ERROR_ON_RENAME
|
||||
RENAME TABLE t1 TO t1new;
|
||||
--replace_regex /(tablespace|key_id) [1-9][0-9]*/\1 /
|
||||
|
||||
# Alter table rename is not allowed with incorrect keys
|
||||
--error ER_GET_ERRMSG
|
||||
ALTER TABLE t1new RENAME TO t2new;
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
ALTER TABLE t1 RENAME TO t1new;
|
||||
# Drop should pass even with incorrect keys
|
||||
--replace_regex /(tablespace|key_id) [1-9][0-9]*/\1 /
|
||||
DROP TABLE t1new;
|
||||
DROP TABLE t1;
|
||||
|
@@ -11,6 +11,7 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page n
|
||||
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
|
||||
# Suppression for builds where file_key_management plugin is linked statically
|
||||
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
|
||||
|
||||
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
|
||||
--source include/restart_mysqld.inc
|
||||
|
@@ -7,6 +7,7 @@
|
||||
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
|
||||
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
|
||||
call mtr.add_suppression("InnoDB: Unable to decompress ..test.t[1-3]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted");
|
||||
|
||||
--echo # Restart mysqld --file-key-management-filename=keys2.txt
|
||||
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
|
||||
@@ -27,9 +28,9 @@ insert into t3 values (1, repeat('secret',6000));
|
||||
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
|
||||
-- source include/restart_mysqld.inc
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
select count(*) from t1 FORCE INDEX (b) where b like 'secret%';
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
select count(*) from t2 FORCE INDEX (b) where b like 'secret%';
|
||||
select count(*) from t3 FORCE INDEX (b) where b like 'secret%';
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\.");
|
||||
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
|
||||
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[15].ibd looks corrupted; key_version=1");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` is corrupted");
|
||||
|
||||
# Suppression for builds where file_key_management plugin is linked statically
|
||||
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
|
||||
@@ -41,9 +42,9 @@ alter table t1 encrypted='yes' `encryption_key_id`=1;
|
||||
--let $restart_parameters=--innodb-encrypt-tables=OFF
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
select * from t1;
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
select * from t5;
|
||||
|
||||
--let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
|
||||
|
@@ -8,6 +8,7 @@
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version=3221342974");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` is corrupted");
|
||||
|
||||
SET GLOBAL innodb_file_per_table = ON;
|
||||
set global innodb_compression_algorithm = 1;
|
||||
@@ -65,11 +66,11 @@ EOF
|
||||
|
||||
--source include/start_mysqld.inc
|
||||
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t1;
|
||||
--error ER_GET_ERRMSG
|
||||
SELECT * FROM t2;
|
||||
--error ER_GET_ERRMSG
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT * FROM t3;
|
||||
|
||||
--source include/shutdown_mysqld.inc
|
||||
|
@@ -10,6 +10,7 @@
|
||||
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
|
||||
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
|
||||
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file .*test.t[12].ibd looks corrupted; key_version=1");
|
||||
call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
|
||||
|
||||
--echo # Start server with keys2.txt
|
||||
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
|
||||
@@ -44,11 +45,11 @@ CREATE TABLE t4(a int not null primary key auto_increment, b varchar(128)) engin
|
||||
SELECT SLEEP(5);
|
||||
SELECT COUNT(1) FROM t3;
|
||||
SELECT COUNT(1) FROM t2;
|
||||
--error 1296
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT COUNT(1) FROM t2,t1 where t2.a = t1.a;
|
||||
--error 1296
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT COUNT(1) FROM t1 where b = 'ab';
|
||||
--error 1296
|
||||
--error ER_NO_SUCH_TABLE_IN_ENGINE
|
||||
SELECT COUNT(1) FROM t1;
|
||||
|
||||
--echo
|
||||
|
Reference in New Issue
Block a user