Debian Codegraph @

mysql-test/suite/encryption/t/corrupted_during_recovery.test

raw
1 --source include/have_innodb.inc
2 --source include/have_file_key_management_plugin.inc
3
4 --disable_query_log
5 call mtr.add_suppression("InnoDB: Plugin initialization aborted");
6 call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
7 call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
8 call mtr.add_suppression("InnoDB: Failed to read page [123] from file '.*test.t1\\.ibd': Table is compressed or encrypted but uncompress or decrypt failed");
9 call mtr.add_suppression("InnoDB: The page \\[page id: space=\\d+, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted");
10 call mtr.add_suppression("InnoDB: File '.*test/t1\\.ibd' is corrupted");
11 call mtr.add_suppression("InnoDB: Table in tablespace \\d+ encrypted. However key management plugin or used key_version \\d+ is not found or used encryption algorithm or method does not match. Can't continue opening the table.");
12 call mtr.add_suppression("InnoDB: Unable to apply log to corrupted page ");
13 call mtr.add_suppression("Fewer engines are enabled now than were before the crash");
14 --enable_query_log
15
16 let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
17 CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
18 INSERT INTO t1 VALUES(1);
19 # Force a redo log checkpoint.
20 let $restart_noprint=2;
21 --source include/restart_mysqld.inc
22 --source ../../suite/innodb/include/no_checkpoint_start.inc
23 CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB, ENCRYPTED=YES;
24 INSERT INTO t1 VALUES(2);
25 SET GLOBAL innodb_flush_log_at_trx_commit=1;
26 INSERT INTO t2 VALUES(2);
27
28 --let CLEANUP_IF_CHECKPOINT=DROP TABLE t1,t2;
29 --source ../../suite/innodb/include/no_checkpoint_end.inc
30
31 --echo # Corrupt the pages
32
33 perl;
34 my $ps = $ENV{INNODB_PAGE_SIZE};
35
36 my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
37 open(FILE, "+<$file") || die "Unable to open $file";
38 binmode FILE;
39 my $offset = ($ENV{INNODB_CHECKSUM_ALGORITHM} =~ /full_crc32/) ? 26 : 0;
40 seek (FILE, $ENV{INNODB_PAGE_SIZE} * 3 + $offset, SEEK_SET) or die "seek";
41 print FILE "junk";
42 close FILE or die "close";
43
44 $file = "$ENV{MYSQLD_DATADIR}/test/t2.ibd";
45 open(FILE, "+<$file") || die "Unable to open $file";
46 binmode FILE;
47 # Corrupt pages 1 to 3. MLOG_INIT_FILE_PAGE2 should protect us!
48 # Unfortunately, we are not immune to page 0 corruption.
49 seek (FILE, $ps, SEEK_SET) or die "seek";
50 print FILE chr(0xff) x ($ps * 3);
51 close FILE or die "close";
52 EOF
53
54 --source include/start_mysqld.inc
55 --error ER_UNKNOWN_STORAGE_ENGINE
56 SELECT * FROM t1;
57 --disable_query_log
58 call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[1].ibd looks corrupted; key_version=");
59 call mtr.add_suppression("Table .*t1.* is corrupted. Please drop the table and recreate.");
60 --enable_query_log
61 let $restart_parameters=--innodb_force_recovery=1 --skip-innodb-buffer-pool-load-at-startup;
62 --source include/restart_mysqld.inc
63
64 --error ER_TABLE_CORRUPT
65 SELECT * FROM t1;
66 SELECT * FROM t2;
67 CHECK TABLE t2;
68
69 DROP TABLE t1, t2;