Commit 77b43995 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-33421 innodb.corrupted_during_recovery fails due to error that the table is corrupted

This fixes up the merge commit 7e39470e

dict_table_open_on_name(): Report ER_TABLE_CORRUPT in a consistent
fashion, with a pretty-printed table name.
parent f30244d1
...@@ -9,7 +9,7 @@ INSERT INTO t2 VALUES(2); ...@@ -9,7 +9,7 @@ INSERT INTO t2 VALUES(2);
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB' ERROR 42000: Unknown storage engine 'InnoDB'
SELECT * FROM t1; SELECT * FROM t1;
Got one of the listed errors ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
SELECT * FROM t2; SELECT * FROM t2;
a a
2 2
......
...@@ -32,7 +32,7 @@ foobar 2 ...@@ -32,7 +32,7 @@ foobar 2
# Restart server with keysbad3.txt # Restart server with keysbad3.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keysbad3.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keysbad3.txt
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keysbad3.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keysbad3.txt
DROP TABLE t1; DROP TABLE t1;
# Start server with keys3.txt # Start server with keys3.txt
...@@ -44,31 +44,31 @@ INSERT INTO t2 VALUES ('foobar',1,2); ...@@ -44,31 +44,31 @@ INSERT INTO t2 VALUES ('foobar',1,2);
# Restart server with keys2.txt # Restart server with keys2.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
SELECT * FROM t2; SELECT * FROM t2;
ERROR 42S02: Table 'test.t2' doesn't exist in engine ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
SELECT * FROM t2 where id = 1; SELECT * FROM t2 where id = 1;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
SELECT * FROM t2 where b = 1; SELECT * FROM t2 where b = 1;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
INSERT INTO t2 VALUES ('tmp',3,3); INSERT INTO t2 VALUES ('tmp',3,3);
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
DELETE FROM t2 where b = 3; DELETE FROM t2 where b = 3;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
DELETE FROM t2 where id = 3; DELETE FROM t2 where id = 3;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
UPDATE t2 set b = b +1; UPDATE t2 set b = b +1;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
OPTIMIZE TABLE t2; OPTIMIZE TABLE t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 optimize Error Table test/t2 is corrupted. Please drop the table and recreate. test.t2 optimize Error Table `test`.`t2` is corrupted. Please drop the table and recreate.
test.t2 optimize error Corrupt test.t2 optimize error Corrupt
ALTER TABLE t2 ADD COLUMN d INT; ALTER TABLE t2 ADD COLUMN d INT;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
ANALYZE TABLE t2; ANALYZE TABLE t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 analyze Error Table test/t2 is corrupted. Please drop the table and recreate. test.t2 analyze Error Table `test`.`t2` is corrupted. Please drop the table and recreate.
test.t2 analyze error Corrupt test.t2 analyze error Corrupt
TRUNCATE TABLE t2; TRUNCATE TABLE t2;
ERROR HY000: Table test/t2 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
DROP TABLE t2; DROP TABLE t2;
# Start server with keys2.txt # Start server with keys2.txt
......
...@@ -14,24 +14,24 @@ ENCRYPTED=YES ENCRYPTION_KEY_ID=4; ...@@ -14,24 +14,24 @@ ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt # restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
Error 1932 Table 'test.t1' doesn't exist in engine Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
ALTER TABLE t1 ENGINE=InnoDB; ALTER TABLE t1 ENGINE=InnoDB;
ERROR HY000: Table test/t1 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
Error 1877 Table test/t1 is corrupted. Please drop the table and recreate. Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize Error Table test/t1 is corrupted. Please drop the table and recreate. test.t1 optimize Error Table `test`.`t1` is corrupted. Please drop the table and recreate.
test.t1 optimize error Corrupt test.t1 optimize error Corrupt
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
CHECK TABLE t1; CHECK TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check Error Table test/t1 is corrupted. Please drop the table and recreate. test.t1 check Error Table `test`.`t1` is corrupted. Please drop the table and recreate.
test.t1 check error Corrupt test.t1 check error Corrupt
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
...@@ -41,7 +41,7 @@ backup: t1 ...@@ -41,7 +41,7 @@ backup: t1
UNLOCK TABLES; UNLOCK TABLES;
# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt # restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
ALTER TABLE t1 DISCARD TABLESPACE; ALTER TABLE t1 DISCARD TABLESPACE;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB
ENCRYPTED=YES ENCRYPTION_KEY_ID=4; ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
...@@ -62,7 +62,7 @@ t1 CREATE TABLE `t1` ( ...@@ -62,7 +62,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`=YES `ENCRYPTION_KEY_ID`=4 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `ENCRYPTED`=YES `ENCRYPTION_KEY_ID`=4
# restart: --innodb-encrypt-tables --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt # restart: --innodb-encrypt-tables --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
RENAME TABLE t1 TO t1new; RENAME TABLE t1 TO t1new;
ERROR HY000: Error on rename of './test/t1' to './test/t1new' (errno: 155 "The table does not exist in the storage engine") ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
ALTER TABLE t1 RENAME TO t1new; ALTER TABLE t1 RENAME TO t1new;
ERROR HY000: Table test/t1 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
DROP TABLE t1; DROP TABLE t1;
...@@ -12,13 +12,13 @@ INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); ...@@ -12,13 +12,13 @@ INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt # restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize Error Table 'test.t1' doesn't exist in engine test.t1 optimize Error Table `test`.`t1` is corrupted. Please drop the table and recreate.
test.t1 optimize status Operation failed test.t1 optimize error Corrupt
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
CHECK TABLE t1; CHECK TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check Error Table test/t1 is corrupted. Please drop the table and recreate. test.t1 check Error Table `test`.`t1` is corrupted. Please drop the table and recreate.
test.t1 check error Corrupt test.t1 check error Corrupt
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
......
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; key_version=1"); 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; key_version=1");
call mtr.add_suppression("InnoDB: Recovery failed to read page"); call mtr.add_suppression("InnoDB: Recovery failed to read page");
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: 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"); call mtr.add_suppression("Table `test`\\.`t[12]` is corrupted");
# Restart mysqld --file-key-management-filename=keys2.txt # Restart mysqld --file-key-management-filename=keys2.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
SET GLOBAL innodb_file_per_table = ON; SET GLOBAL innodb_file_per_table = ON;
...@@ -17,9 +17,9 @@ insert into t3 values (1, repeat('secret',6000)); ...@@ -17,9 +17,9 @@ insert into t3 values (1, repeat('secret',6000));
# Restart mysqld --file-key-management-filename=keys3.txt # Restart mysqld --file-key-management-filename=keys3.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
select count(*) from t1 FORCE INDEX (b) where b like 'secret%'; select count(*) from t1 FORCE INDEX (b) where b like 'secret%';
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
select count(*) from t2 FORCE INDEX (b) where b like 'secret%'; select count(*) from t2 FORCE INDEX (b) where b like 'secret%';
ERROR 42S02: Table 'test.t2' doesn't exist in engine ERROR HY000: Table `test`.`t2` is corrupted. Please drop the table and recreate.
select count(*) from t3 FORCE INDEX (b) where b like 'secret%'; select count(*) from t3 FORCE INDEX (b) where b like 'secret%';
count(*) count(*)
1 1
......
call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` (has an unreadable root page|is corrupted)"); call mtr.add_suppression("Table `test`\\.`t[15]` (has an unreadable root page|is corrupted)");
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("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("InnoDB: Recovery failed to read page"); call mtr.add_suppression("InnoDB: Recovery failed to read page");
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: 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");
call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
create table t5 ( create table t5 (
...@@ -24,9 +23,9 @@ insert into t1 values (1,2,'maria','db','encryption'); ...@@ -24,9 +23,9 @@ insert into t1 values (1,2,'maria','db','encryption');
alter table t1 encrypted='yes' `encryption_key_id`=1; alter table t1 encrypted='yes' `encryption_key_id`=1;
# restart: --innodb-encrypt-tables=OFF # restart: --innodb-encrypt-tables=OFF
select * from t1; select * from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
select * from t5; select * from t5;
ERROR 42S02: Table 'test.t5' doesn't exist in engine ERROR HY000: Table `test`.`t5` is corrupted. Please drop the table and recreate.
# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
drop table t1; drop table t1;
drop table t5; drop table t5;
call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` (has an unreadable root page|is corrupted)"); call mtr.add_suppression("Table `test`\\.`t[13]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version="); call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version=");
call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table"); call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table");
call mtr.add_suppression("\\[ERROR\\] (mysqld|mariadbd).*: Index for table 't2' is corrupt; try to repair it"); call mtr.add_suppression("\\[ERROR\\] (mysqld|mariadbd).*: Index for table 't2' is corrupt; try to repair it");
...@@ -18,11 +18,11 @@ COMMIT; ...@@ -18,11 +18,11 @@ COMMIT;
# Corrupt tables # Corrupt tables
# restart # restart
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
SELECT * FROM t2; SELECT * FROM t2;
Got one of the listed errors Got one of the listed errors
SELECT * FROM t3; SELECT * FROM t3;
ERROR 42S02: Table 'test.t3' doesn't exist in engine ERROR HY000: Table `test`.`t3` is corrupted. Please drop the table and recreate.
# Restore the original tables # Restore the original tables
# restart # restart
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
...@@ -38,11 +38,11 @@ SELECT COUNT(1) FROM t2; ...@@ -38,11 +38,11 @@ SELECT COUNT(1) FROM t2;
COUNT(1) COUNT(1)
2048 2048
SELECT COUNT(1) FROM t2,t1 where t2.a = t1.a; SELECT COUNT(1) FROM t2,t1 where t2.a = t1.a;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
SELECT COUNT(1) FROM t1 where b = 'ab'; SELECT COUNT(1) FROM t1 where b = 'ab';
ERROR HY000: Table test/t1 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
SELECT COUNT(1) FROM t1; SELECT COUNT(1) FROM t1;
ERROR HY000: Table test/t1 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
# Start server with keys2.txt # Start server with keys2.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt # restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
......
...@@ -60,7 +60,7 @@ call mtr.add_suppression("Table .*t1.* is corrupted. Please drop the table and r ...@@ -60,7 +60,7 @@ call mtr.add_suppression("Table .*t1.* is corrupted. Please drop the table and r
let $restart_parameters=--innodb_force_recovery=1 --skip-innodb-buffer-pool-load-at-startup; let $restart_parameters=--innodb_force_recovery=1 --skip-innodb-buffer-pool-load-at-startup;
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE,ER_TABLE_CORRUPT --error ER_TABLE_CORRUPT
SELECT * FROM t1; SELECT * FROM t1;
SELECT * FROM t2; SELECT * FROM t2;
CHECK TABLE t2; CHECK TABLE t2;
......
...@@ -43,7 +43,7 @@ SELECT * FROM t1; ...@@ -43,7 +43,7 @@ SELECT * FROM t1;
-- source include/restart_mysqld.inc -- source include/restart_mysqld.inc
--disable_warnings --disable_warnings
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT * FROM t1; SELECT * FROM t1;
--enable_warnings --enable_warnings
...@@ -72,7 +72,7 @@ INSERT INTO t2 VALUES ('foobar',1,2); ...@@ -72,7 +72,7 @@ INSERT INTO t2 VALUES ('foobar',1,2);
-- source include/restart_mysqld.inc -- source include/restart_mysqld.inc
--disable_warnings --disable_warnings
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT * FROM t2; SELECT * FROM t2;
--error ER_TABLE_CORRUPT --error ER_TABLE_CORRUPT
......
...@@ -32,7 +32,7 @@ INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); ...@@ -32,7 +32,7 @@ INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT * FROM t1; SELECT * FROM t1;
--replace_regex /key_id [1-9][0-9]*/\1 / --replace_regex /key_id [1-9][0-9]*/\1 /
SHOW WARNINGS; SHOW WARNINGS;
...@@ -63,7 +63,7 @@ UNLOCK TABLES; ...@@ -63,7 +63,7 @@ UNLOCK TABLES;
--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
ALTER TABLE t1 DISCARD TABLESPACE; ALTER TABLE t1 DISCARD TABLESPACE;
# Drop table will succeed. # Drop table will succeed.
DROP TABLE t1; DROP TABLE t1;
...@@ -95,7 +95,7 @@ SHOW CREATE TABLE t1; ...@@ -95,7 +95,7 @@ SHOW CREATE TABLE t1;
--let $restart_parameters= --innodb-encrypt-tables --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --let $restart_parameters= --innodb-encrypt-tables --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--error ER_ERROR_ON_RENAME --error ER_TABLE_CORRUPT
RENAME TABLE t1 TO t1new; RENAME TABLE t1 TO t1new;
--error ER_TABLE_CORRUPT --error ER_TABLE_CORRUPT
ALTER TABLE t1 RENAME TO t1new; ALTER TABLE t1 RENAME TO t1new;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +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; key_version=1"); 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; key_version=1");
call mtr.add_suppression("InnoDB: Recovery failed to read page"); call mtr.add_suppression("InnoDB: Recovery failed to read page");
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: 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"); call mtr.add_suppression("Table `test`\\.`t[12]` is corrupted");
--echo # Restart mysqld --file-key-management-filename=keys2.txt --echo # Restart mysqld --file-key-management-filename=keys2.txt
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
...@@ -28,9 +28,9 @@ insert into t3 values (1, repeat('secret',6000)); ...@@ -28,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 -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
-- source include/restart_mysqld.inc -- source include/restart_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
select count(*) from t1 FORCE INDEX (b) where b like 'secret%'; select count(*) from t1 FORCE INDEX (b) where b like 'secret%';
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
select count(*) from t2 FORCE INDEX (b) where b like 'secret%'; select count(*) from t2 FORCE INDEX (b) where b like 'secret%';
select count(*) from t3 FORCE INDEX (b) where b like 'secret%'; select count(*) from t3 FORCE INDEX (b) where b like 'secret%';
......
...@@ -7,11 +7,10 @@ ...@@ -7,11 +7,10 @@
# MDEV-9559: Server without encryption configs crashes if selecting from an implicitly encrypted table # MDEV-9559: Server without encryption configs crashes if selecting from an implicitly encrypted table
# #
call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` (has an unreadable root page|is corrupted)"); call mtr.add_suppression("Table `test`\\.`t[15]` (has an unreadable root page|is corrupted)");
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("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("InnoDB: Recovery failed to read page"); call mtr.add_suppression("InnoDB: Recovery failed to read page");
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: 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 # 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("Couldn't load plugins from 'file_key_management");
...@@ -43,9 +42,9 @@ alter table t1 encrypted='yes' `encryption_key_id`=1; ...@@ -43,9 +42,9 @@ alter table t1 encrypted='yes' `encryption_key_id`=1;
--let $restart_parameters=--innodb-encrypt-tables=OFF --let $restart_parameters=--innodb-encrypt-tables=OFF
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
select * from t1; select * from t1;
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
select * from t5; select * from t5;
--let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# Don't test under embedded # Don't test under embedded
-- source include/not_embedded.inc -- source include/not_embedded.inc
call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` (has an unreadable root page|is corrupted)"); call mtr.add_suppression("Table `test`\\.`t[13]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version="); call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version=");
call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table"); call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption in an InnoDB type table");
call mtr.add_suppression("\\[ERROR\\] (mysqld|mariadbd).*: Index for table 't2' is corrupt; try to repair it"); call mtr.add_suppression("\\[ERROR\\] (mysqld|mariadbd).*: Index for table 't2' is corrupt; try to repair it");
...@@ -68,11 +68,11 @@ EOF ...@@ -68,11 +68,11 @@ EOF
--source include/start_mysqld.inc --source include/start_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT * FROM t1; SELECT * FROM t1;
--error ER_GET_ERRMSG,ER_NOT_KEYFILE --error ER_GET_ERRMSG,ER_NOT_KEYFILE
SELECT * FROM t2; SELECT * FROM t2;
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT * FROM t3; SELECT * FROM t3;
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc
......
...@@ -46,7 +46,7 @@ CREATE TABLE t4(a int not null primary key auto_increment, b varchar(128)) engin ...@@ -46,7 +46,7 @@ CREATE TABLE t4(a int not null primary key auto_increment, b varchar(128)) engin
SELECT SLEEP(5); SELECT SLEEP(5);
SELECT COUNT(1) FROM t3; SELECT COUNT(1) FROM t3;
SELECT COUNT(1) FROM t2; SELECT COUNT(1) FROM t2;
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT COUNT(1) FROM t2,t1 where t2.a = t1.a; SELECT COUNT(1) FROM t2,t1 where t2.a = t1.a;
--error ER_TABLE_CORRUPT --error ER_TABLE_CORRUPT
SELECT COUNT(1) FROM t1 where b = 'ab'; SELECT COUNT(1) FROM t1 where b = 'ab';
......
...@@ -15,9 +15,9 @@ disconnect con1; ...@@ -15,9 +15,9 @@ disconnect con1;
# and recompute innodb_checksum_algorithm=crc32 # and recompute innodb_checksum_algorithm=crc32
# restart # restart
SELECT COUNT(*) FROM bug16720368; SELECT COUNT(*) FROM bug16720368;
ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine ERROR HY000: Table `test`.`bug16720368` is corrupted. Please drop the table and recreate.
INSERT INTO bug16720368 VALUES(1); INSERT INTO bug16720368 VALUES(1);
ERROR HY000: Table test/bug16720368 is corrupted. Please drop the table and recreate. ERROR HY000: Table `test`.`bug16720368` is corrupted. Please drop the table and recreate.
INSERT INTO bug16720368_1 VALUES(1); INSERT INTO bug16720368_1 VALUES(1);
# Shut down the server to uncorrupt the data. # Shut down the server to uncorrupt the data.
# restart # restart
......
...@@ -76,7 +76,7 @@ EOF ...@@ -76,7 +76,7 @@ EOF
-- source include/start_mysqld.inc -- source include/start_mysqld.inc
--error ER_NO_SUCH_TABLE_IN_ENGINE --error ER_TABLE_CORRUPT
SELECT COUNT(*) FROM bug16720368; SELECT COUNT(*) FROM bug16720368;
--error ER_TABLE_CORRUPT --error ER_TABLE_CORRUPT
INSERT INTO bug16720368 VALUES(1); INSERT INTO bug16720368 VALUES(1);
......
...@@ -7,7 +7,7 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile ...@@ -7,7 +7,7 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t1\\.ibd' page"); call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t1\\.ibd' page");
call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test.t1\\.ibd': Page read from tablespace is corrupted."); call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test.t1\\.ibd': Page read from tablespace is corrupted.");
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page .*, page number=3\\]"); call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page .*, page number=3\\]");
call mtr.add_suppression("Table test/t1 is corrupted. Please drop the table and recreate\\."); call mtr.add_suppression("Table `test`.`t1` is corrupted. Please drop the table and recreate.");
call mtr.add_suppression("InnoDB: File '.*test/t1\\.ibd' is corrupted"); call mtr.add_suppression("InnoDB: File '.*test/t1\\.ibd' is corrupted");
call mtr.add_suppression("InnoDB: A long wait .* was observed for dict_sys"); call mtr.add_suppression("InnoDB: A long wait .* was observed for dict_sys");
--enable_query_log --enable_query_log
......
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
-# restart: --disable-provider-bzip2 -# restart: --disable-provider-bzip2
+# restart: --disable-provider-lz4 +# restart: --disable-provider-lz4
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
show warnings; show warnings;
Level Code Message Level Code Message
-Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded -Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded
+Warning 4185 MariaDB tried to use the LZ4 compression, but its provider plugin is not loaded +Warning 4185 MariaDB tried to use the LZ4 compression, but its provider plugin is not loaded
Error 1932 Table 'test.t1' doesn't exist in engine Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
drop table t1; drop table t1;
# restart # restart
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
-# restart: --disable-provider-bzip2 -# restart: --disable-provider-bzip2
+# restart: --disable-provider-lzma +# restart: --disable-provider-lzma
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
show warnings; show warnings;
Level Code Message Level Code Message
-Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded -Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded
+Warning 4185 MariaDB tried to use the LZMA compression, but its provider plugin is not loaded +Warning 4185 MariaDB tried to use the LZMA compression, but its provider plugin is not loaded
Error 1932 Table 'test.t1' doesn't exist in engine Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
drop table t1; drop table t1;
# restart # restart
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
-# restart: --disable-provider-bzip2 -# restart: --disable-provider-bzip2
+# restart: --disable-provider-lzo +# restart: --disable-provider-lzo
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
show warnings; show warnings;
Level Code Message Level Code Message
-Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded -Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded
+Warning 4185 MariaDB tried to use the LZO compression, but its provider plugin is not loaded +Warning 4185 MariaDB tried to use the LZO compression, but its provider plugin is not loaded
Error 1932 Table 'test.t1' doesn't exist in engine Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
drop table t1; drop table t1;
# restart # restart
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
-# restart: --disable-provider-bzip2 -# restart: --disable-provider-bzip2
+# restart: --disable-provider-snappy +# restart: --disable-provider-snappy
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
show warnings; show warnings;
Level Code Message Level Code Message
-Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded -Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded
+Warning 4185 MariaDB tried to use the Snappy compression, but its provider plugin is not loaded +Warning 4185 MariaDB tried to use the Snappy compression, but its provider plugin is not loaded
Error 1932 Table 'test.t1' doesn't exist in engine Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
drop table t1; drop table t1;
# restart # restart
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
-# restart: --disable-provider-bzip2 -# restart: --disable-provider-bzip2
+# restart: --disable-provider-lz4 +# restart: --disable-provider-lz4
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist in engine -ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
-show warnings; -show warnings;
-Level Code Message -Level Code Message
-Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded -Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded
-Error 1932 Table 'test.t1' doesn't exist in engine -Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
+a left(b, 9) length(b) +a left(b, 9) length(b)
+0 0 +0 0
+1 0 +1 0
......
...@@ -18,10 +18,10 @@ a left(b, 9) length(b) ...@@ -18,10 +18,10 @@ a left(b, 9) length(b)
2 ghighighi 30000 2 ghighighi 30000
# restart: --disable-provider-bzip2 # restart: --disable-provider-bzip2
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine ERROR HY000: Table `test`.`t1` is corrupted. Please drop the table and recreate.
show warnings; show warnings;
Level Code Message Level Code Message
Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded Warning 4185 MariaDB tried to use the BZip2 compression, but its provider plugin is not loaded
Error 1932 Table 'test.t1' doesn't exist in engine Error 1877 Table `test`.`t1` is corrupted. Please drop the table and recreate.
drop table t1; drop table t1;
# restart # restart
...@@ -40,7 +40,7 @@ let $restart_parameters = --disable-provider-$alg; ...@@ -40,7 +40,7 @@ let $restart_parameters = --disable-provider-$alg;
source include/restart_mysqld.inc; source include/restart_mysqld.inc;
if ($engine == "innodb") { if ($engine == "innodb") {
error ER_NO_SUCH_TABLE_IN_ENGINE; error ER_TABLE_CORRUPT;
select a, left(b, 9), length(b) from t1; select a, left(b, 9), length(b) from t1;
show warnings; show warnings;
} }
......
...@@ -1007,6 +1007,17 @@ ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() ...@@ -1007,6 +1007,17 @@ ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze()
} }
#endif /* UNIV_PFS_RWLOCK */ #endif /* UNIV_PFS_RWLOCK */
/** Report an error about failing to open a table.
@param name table name */
static void dict_table_open_failed(const table_name_t &name)
{
my_printf_error(ER_TABLE_CORRUPT,
"Table %`.*s.%`s is corrupted."
" Please drop the table and recreate.",
MYF(ME_ERROR_LOG),
int(name.dblen()), name.m_name, name.basename());
}
/**********************************************************************//** /**********************************************************************//**
Returns a table object and increments its open handle count. Returns a table object and increments its open handle count.
NOTE! This is a high-level function to be used mainly from outside the NOTE! This is a high-level function to be used mainly from outside the
...@@ -1039,18 +1050,20 @@ dict_table_open_on_name( ...@@ -1039,18 +1050,20 @@ dict_table_open_on_name(
if (!(ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY) && if (!(ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY) &&
!table->is_readable() && table->corrupted) !table->is_readable() && table->corrupted)
{ {
ulint algo = table->space->get_compression_algo(); ulint algo= table->space->get_compression_algo();
if (algo <= PAGE_ALGORITHM_LAST && !fil_comp_algo_loaded(algo)) { if (algo <= PAGE_ALGORITHM_LAST && !fil_comp_algo_loaded(algo))
my_printf_error(ER_PROVIDER_NOT_LOADED, my_printf_error(ER_PROVIDER_NOT_LOADED,
"Table %s is compressed with %s, which is not currently loaded. " "Table %`.*s.%`s is compressed with %s,"
"Please load the %s provider plugin to open the table", " which is not currently loaded. "
MYF(ME_ERROR_LOG), table->name, "Please load the %s provider plugin"
page_compression_algorithms[algo], page_compression_algorithms[algo]); " to open the table",
} else { MYF(ME_ERROR_LOG),
my_printf_error(ER_TABLE_CORRUPT, int(table->name.dblen()), table->name.m_name,
"Table %s is corrupted. Please drop the table and recreate.", table->name.basename(),
MYF(ME_ERROR_LOG), table->name); page_compression_algorithms[algo],
} page_compression_algorithms[algo]);
else
dict_table_open_failed(table->name);
dict_sys.unfreeze(); dict_sys.unfreeze();
DBUG_RETURN(nullptr); DBUG_RETURN(nullptr);
} }
...@@ -1070,8 +1083,7 @@ dict_table_open_on_name( ...@@ -1070,8 +1083,7 @@ dict_table_open_on_name(
if (!(ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY) && if (!(ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY) &&
!table->is_readable() && table->corrupted) !table->is_readable() && table->corrupted)
{ {
ib::error() << "Table " << table->name dict_table_open_failed(table->name);
<< " is corrupted. Please drop the table and recreate.";
if (!dict_locked) if (!dict_locked)
dict_sys.unlock(); dict_sys.unlock();
DBUG_RETURN(nullptr); DBUG_RETURN(nullptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment