| 1 |
--source include/have_innodb.inc |
| 2 |
|
| 3 |
--disable_query_log |
| 4 |
call mtr.add_suppression("InnoDB: Plugin initialization aborted"); |
| 5 |
call mtr.add_suppression("Plugin 'InnoDB' init function returned error"); |
| 6 |
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed"); |
| 7 |
call mtr.add_suppression("InnoDB: Unable to apply log to corrupted page 3 in file .*test.t1\\.ibd"); |
| 8 |
call mtr.add_suppression("Table `test`.`t1` is corrupted. Please drop the table and recreate\\."); |
| 9 |
call mtr.add_suppression("InnoDB: File '.*test/t1\\.ibd' is corrupted"); |
| 10 |
call mtr.add_suppression("InnoDB: A long wait .* was observed for dict_sys"); |
| 11 |
call mtr.add_suppression("InnoDB: Page \\[page id: space=[1-9][0-9]*, page number=3\\] log sequence number 1311768467463790320 is in the future!"); |
| 12 |
call mtr.add_suppression("InnoDB: Your database may be corrupt"); |
| 13 |
call mtr.add_suppression("InnoDB: MySQL-8\\.0 tablespace in .*test/t2\\.ibd"); |
| 14 |
call mtr.add_suppression("InnoDB: Restart in MySQL for migration/recovery\\."); |
| 15 |
call mtr.add_suppression("Fewer engines are enabled now than were before the crash"); |
| 16 |
--enable_query_log |
| 17 |
|
| 18 |
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
| 19 |
let ALGO=`select @@innodb_checksum_algorithm`; |
| 20 |
CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB; |
| 21 |
INSERT INTO t1 VALUES(1); |
| 22 |
# Force a redo log checkpoint. |
| 23 |
let $restart_noprint=2; |
| 24 |
--source include/restart_mysqld.inc |
| 25 |
--source ../include/no_checkpoint_start.inc |
| 26 |
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB; |
| 27 |
INSERT INTO t1 VALUES(2); |
| 28 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 29 |
INSERT INTO t2 VALUES(1); |
| 30 |
|
| 31 |
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1,t2; |
| 32 |
--source ../include/no_checkpoint_end.inc |
| 33 |
|
| 34 |
--echo # Corrupt the pages |
| 35 |
|
| 36 |
perl; |
| 37 |
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; |
| 38 |
my $polynomial = 0x82f63b78; # CRC-32C |
| 39 |
my $algo = $ENV{ALGO}; |
| 40 |
my $ps = $ENV{INNODB_PAGE_SIZE}; |
| 41 |
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; |
| 42 |
open(FILE, "+<$file") || die "Unable to open $file"; |
| 43 |
binmode FILE; |
| 44 |
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n"; |
| 45 |
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; |
| 46 |
# Assign a future FIL_PAGE_LSN |
| 47 |
substr($page, 16, 8) = pack("NN", 0x12345678, 0x9abcdef0); |
| 48 |
substr($page, $ps - 8, 8) = pack("NN", 0x9abcdef0, 0x9abcdef0); |
| 49 |
if ($algo =~ /full_crc32/) |
| 50 |
{ |
| 51 |
my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial); |
| 52 |
substr($page, $ps - 4, 4) = pack("N", $ck); |
| 53 |
} |
| 54 |
else |
| 55 |
{ |
| 56 |
# Replace the innodb_checksum_algorithm=crc32 checksum |
| 57 |
my $ck= pack("N", |
| 58 |
mycrc32(substr($page, 4, 22), 0, $polynomial) ^ |
| 59 |
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial)); |
| 60 |
substr ($page, 0, 4) = $ck; |
| 61 |
substr ($page, $ps - 8, 4) = $ck; |
| 62 |
} |
| 63 |
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n"; |
| 64 |
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; |
| 65 |
close FILE or die "close"; |
| 66 |
|
| 67 |
$file = "$ENV{MYSQLD_DATADIR}/test/t2.ibd"; |
| 68 |
open(FILE, "+<$file") || die "Unable to open $file"; |
| 69 |
binmode FILE; |
| 70 |
# Corrupt pages 0 to 3. INIT_PAGE should protect us! |
| 71 |
print FILE chr(0xff) x ($ps * 4); |
| 72 |
close FILE or die "close"; |
| 73 |
EOF |
| 74 |
|
| 75 |
--source include/start_mysqld.inc |
| 76 |
--error ER_UNKNOWN_STORAGE_ENGINE |
| 77 |
SELECT * FROM t1; |
| 78 |
|
| 79 |
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; |
| 80 |
let SEARCH_PATTERN=InnoDB: Page \\[page id: space=[1-9][0-9]*, page number=3\\] log sequence number 1311768467463790320 is in the future!; |
| 81 |
--source include/search_pattern_in_file.inc |
| 82 |
|
| 83 |
let $restart_parameters=--innodb_force_recovery=1; |
| 84 |
--source include/restart_mysqld.inc |
| 85 |
|
| 86 |
--error 0,ER_NO_SUCH_TABLE_IN_ENGINE |
| 87 |
SELECT * FROM t1; |
| 88 |
SELECT * FROM t2; |
| 89 |
CHECK TABLE t2; |
| 90 |
|
| 91 |
DROP TABLE t1, t2; |
| 92 |
|
| 93 |
# MDEV-21572 buf_page_get_gen() should apply buffered page |
| 94 |
# initialized redo log during recovery |
| 95 |
--source ../include/no_checkpoint_start.inc |
| 96 |
CREATE TABLE t1(pk SERIAL) ENGINE=InnoDB; |
| 97 |
INSERT INTO t1 VALUES (1),(2),(3); |
| 98 |
connect (con1,localhost,root,,); |
| 99 |
BEGIN; |
| 100 |
DELETE FROM t1 WHERE pk=1; |
| 101 |
connection default; |
| 102 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 103 |
DELETE FROM t1 WHERE pk=3; |
| 104 |
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; |
| 105 |
--source ../include/no_checkpoint_end.inc |
| 106 |
disconnect con1; |
| 107 |
|
| 108 |
--echo # Corrupt the page |
| 109 |
perl; |
| 110 |
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl"; |
| 111 |
my $polynomial = 0x82f63b78; # CRC-32C |
| 112 |
my $algo = $ENV{ALGO}; |
| 113 |
my $ps = $ENV{INNODB_PAGE_SIZE}; |
| 114 |
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; |
| 115 |
open(FILE, "+<$file") || die "Unable to open $file"; |
| 116 |
binmode FILE; |
| 117 |
sysseek(FILE, $ps * 3, SEEK_SET) or die "seek"; |
| 118 |
sysread(FILE, $page, $ps)==$ps||die "Unable to read $file\n"; |
| 119 |
# Set FIL_PAGE_LSN to the maximum |
| 120 |
substr($page, 16, 8) = chr(255) x 8; |
| 121 |
substr($page, $ps - 8, 8) = chr(255) x 8; |
| 122 |
if ($algo =~ /full_crc32/) |
| 123 |
{ |
| 124 |
my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial); |
| 125 |
substr($page, $ps - 4, 4) = pack("N", $ck); |
| 126 |
} |
| 127 |
else |
| 128 |
{ |
| 129 |
# Replace the innodb_checksum_algorithm=crc32 checksum |
| 130 |
my $ck= pack("N", |
| 131 |
mycrc32(substr($page, 4, 22), 0, $polynomial) ^ |
| 132 |
mycrc32(substr($page_, 38, $ps - 38 - 8), 0, $polynomial)); |
| 133 |
substr ($page, 0, 4) = $ck; |
| 134 |
substr ($page, $ps - 8, 4) = $ck; |
| 135 |
} |
| 136 |
sysseek(FILE, $ps * 3, SEEK_SET) or die "seek"; |
| 137 |
syswrite(FILE, $page); |
| 138 |
close FILE or die "close"; |
| 139 |
EOF |
| 140 |
--source include/start_mysqld.inc |
| 141 |
SELECT * FROM t1; |
| 142 |
DROP TABLE t1; |