File: corrupted_during_recovery.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (142 lines) | stat: -rw-r--r-- 5,177 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
--source include/have_innodb.inc

--disable_query_log
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("InnoDB: Unable to apply log to corrupted page 3 in file .*test.t1\\.ibd");
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: A long wait .* was observed for dict_sys");
call mtr.add_suppression("InnoDB: Page \\[page id: space=[1-9][0-9]*, page number=3\\] log sequence number 1311768467463790320 is in the future!");
call mtr.add_suppression("InnoDB: Your database may be corrupt");
call mtr.add_suppression("InnoDB: MySQL-8\\.0 tablespace in .*test/t2\\.ibd");
call mtr.add_suppression("InnoDB: Restart in MySQL for migration/recovery\\.");
call mtr.add_suppression("Fewer engines are enabled now than were before the crash");
--enable_query_log

let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let ALGO=`select @@innodb_checksum_algorithm`;
CREATE TABLE t1(a BIGINT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
# Force a redo log checkpoint.
let $restart_noprint=2;
--source include/restart_mysqld.inc
--source ../include/no_checkpoint_start.inc
CREATE TABLE t2(a BIGINT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(2);
SET GLOBAL innodb_flush_log_at_trx_commit=1;
INSERT INTO t2 VALUES(1);

--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1,t2;
--source ../include/no_checkpoint_end.inc

--echo # Corrupt the pages

perl;
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
my $polynomial = 0x82f63b78; # CRC-32C
my $algo = $ENV{ALGO};
my $ps = $ENV{INNODB_PAGE_SIZE};
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
# Assign a future FIL_PAGE_LSN
substr($page, 16, 8) = pack("NN", 0x12345678, 0x9abcdef0);
substr($page, $ps - 8, 8) = pack("NN", 0x9abcdef0, 0x9abcdef0);
if ($algo =~ /full_crc32/)
{
    my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial);
    substr($page, $ps - 4, 4) = pack("N", $ck);
}
else
{
    # Replace the innodb_checksum_algorithm=crc32 checksum
    my $ck= pack("N",
                 mycrc32(substr($page, 4, 22), 0, $polynomial) ^
                 mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
    substr ($page, 0, 4) = $ck;
    substr ($page, $ps - 8, 4) = $ck;
}
sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close FILE or die "close";

$file = "$ENV{MYSQLD_DATADIR}/test/t2.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
# Corrupt pages 0 to 3. INIT_PAGE should protect us!
print FILE chr(0xff) x ($ps * 4);
close FILE or die "close";
EOF

--source include/start_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;

let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN=InnoDB: Page \\[page id: space=[1-9][0-9]*, page number=3\\] log sequence number 1311768467463790320 is in the future!;
--source include/search_pattern_in_file.inc

let $restart_parameters=--innodb_force_recovery=1;
--source include/restart_mysqld.inc

--error 0,ER_NO_SUCH_TABLE_IN_ENGINE
SELECT * FROM t1;
SELECT * FROM t2;
CHECK TABLE t2;

DROP TABLE t1, t2;

# MDEV-21572 buf_page_get_gen() should apply buffered page
# initialized redo log during recovery
--source ../include/no_checkpoint_start.inc
CREATE TABLE t1(pk SERIAL) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2),(3);
connect (con1,localhost,root,,);
BEGIN;
DELETE FROM t1 WHERE pk=1;
connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE pk=3;
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1;
--source ../include/no_checkpoint_end.inc
disconnect con1;

--echo # Corrupt the page
perl;
do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
my $polynomial = 0x82f63b78; # CRC-32C
my $algo = $ENV{ALGO};
my $ps = $ENV{INNODB_PAGE_SIZE};
my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
sysseek(FILE, $ps * 3, SEEK_SET) or die "seek";
sysread(FILE, $page, $ps)==$ps||die "Unable to read $file\n";
# Set FIL_PAGE_LSN to the maximum
substr($page, 16, 8) = chr(255) x 8;
substr($page, $ps - 8, 8) = chr(255) x 8;
if ($algo =~ /full_crc32/)
{
    my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial);
    substr($page, $ps - 4, 4) = pack("N", $ck);
}
else
{
    # Replace the innodb_checksum_algorithm=crc32 checksum
    my $ck= pack("N",
                 mycrc32(substr($page, 4, 22), 0, $polynomial) ^
                 mycrc32(substr($page_, 38, $ps - 38 - 8), 0, $polynomial));
    substr ($page, 0, 4) = $ck;
    substr ($page, $ps - 8, 4) = $ck;
}
sysseek(FILE, $ps * 3, SEEK_SET) or die "seek";
syswrite(FILE, $page);
close FILE or die "close";
EOF
--source include/start_mysqld.inc
SELECT * FROM t1;
DROP TABLE t1;