Debian Codegraph @

mysql-test/suite/innodb/t/doublewrite.test

raw
1
2 --echo #
3 --echo # MDEV-32242 innodb.doublewrite test case always is skipped
4 --echo #
5
6 --source include/innodb_page_size.inc
7 --source include/not_embedded.inc
8
9 --disable_query_log
10 call mtr.add_suppression("InnoDB: Data file .* uses page size .* but the innodb_page_size start-up parameter is");
11 call mtr.add_suppression("InnoDB: adjusting FSP_SPACE_FLAGS");
12 call mtr.add_suppression("InnoDB: New log files created");
13 call mtr.add_suppression("InnoDB: Cannot create doublewrite buffer: the first file in innodb_data_file_path must be at least (3|6|12)M\\.");
14 call mtr.add_suppression("InnoDB: Database creation was aborted");
15 call mtr.add_suppression("Plugin 'InnoDB' (init function returned error|registration as a STORAGE ENGINE failed)");
16 call mtr.add_suppression("InnoDB: A bad Space ID was found in datafile");
17 call mtr.add_suppression("InnoDB: Checksum mismatch in datafile: ");
18 call mtr.add_suppression("InnoDB: Inconsistent tablespace ID in .*t1\\.ibd");
19 call mtr.add_suppression("\\[Warning\\] Found 1 prepared XA transactions");
20 call mtr.add_suppression("InnoDB: Header page consists of zero bytes in datafile:");
21 call mtr.add_suppression("InnoDB: Page \\[page id: space=[1-9][0-9]*, page number=3\\] log sequence number 18446744073709551615 is in the future!");
22 call mtr.add_suppression("InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the ib_logfile0");
23 call mtr.add_suppression("InnoDB: Plugin initialization aborted");
24 --enable_query_log
25
26 let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
27 let MYSQLD_DATADIR=`select @@datadir`;
28 let ALGO=`select @@innodb_checksum_algorithm`;
29 let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
30
31 create table t1 (f1 int primary key, f2 blob) stats_persistent=0, engine=innodb;
32
33 start transaction;
34 insert into t1 values(1, repeat('#',12));
35 insert into t1 values(2, repeat('+',12));
36 insert into t1 values(3, repeat('/',12));
37 insert into t1 values(4, repeat('-',12));
38 insert into t1 values(5, repeat('.',12));
39 commit work;
40
41 # Slow shutdown and restart to make sure ibuf merge is finished
42 SET GLOBAL innodb_fast_shutdown = 0;
43 let $shutdown_timeout=;
44 --source include/restart_mysqld.inc
45 SET GLOBAL innodb_max_dirty_pages_pct_lwm=0,innodb_max_dirty_pages_pct=0;
46 let $wait_condition =
47 SELECT variable_value = 0
48 FROM information_schema.global_status
49 WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
50 --source include/wait_condition.inc
51 SET GLOBAL innodb_max_dirty_pages_pct=99;
52 --source ../include/no_checkpoint_start.inc
53 connect (dml,localhost,root,,);
54 XA START 'x';
55 insert into t1 values(6, repeat('%', @@innodb_page_size/2));
56 XA END 'x';
57 XA PREPARE 'x';
58 disconnect dml;
59 connection default;
60
61 flush table t1 for export;
62
63 # If we are skipping the test at this point due to an unexpected
64 # checkpoint then page cleaner could be active after reading the
65 # initial checkpoint information
66 --let CLEANUP_IF_CHECKPOINT=XA COMMIT 'x'; drop table t1;
67 --source ../include/no_checkpoint_end.inc
68
69 --copy_file $MYSQLD_DATADIR/ibdata1 $MYSQLD_DATADIR/ibdata1.bak
70 --copy_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile0.bak
71
72 perl;
73 use IO::Handle;
74 do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
75 my $polynomial = 0x82f63b78; # CRC-32C
76 my $algo = $ENV{ALGO};
77 die "Unsupported innodb_checksum_algorithm=$algo\n" unless $algo =~ /crc32/;
78
79 my $fname= "$ENV{'MYSQLD_DATADIR'}test/t1.ibd";
80 my $page_size = $ENV{INNODB_PAGE_SIZE};
81 my $page;
82 do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
83 open(FILE, "+<", $fname) or die;
84 sysseek(FILE, ($page_size/2), 0);
85 syswrite(FILE, chr(0) x ($page_size/2));
86 sysseek(FILE, 3*$page_size, 0);
87 sysread(FILE, $page, $page_size)==$page_size||die "Unable to read $name\n";
88 sysseek(FILE, 3*$page_size, 0)||die "Unable to seek $fname\n";
89 my $corrupted = $page;
90 # Set FIL_PAGE_LSN to the maximum
91 substr($corrupted, 16, 8) = chr(255) x 8;
92 substr($corrupted, $page_size - 8, 8) = chr(255) x 8;
93 if ($algo =~ /full_crc32/)
94 {
95 my $ck = mycrc32(substr($corrupted, 0, $page_size - 4), 0, $polynomial);
96 substr($corrupted, $page_size - 4, 4) = pack("N", $ck);
97 }
98 else
99 {
100 # Replace the innodb_checksum_algorithm=crc32 checksum
101 my $ck= pack("N",
102 mycrc32(substr($corrupted, 4, 22), 0, $polynomial) ^
103 mycrc32(substr($corrupted_, 38, $page_size - 38 - 8), 0,
104 $polynomial));
105 substr ($corrupted, 0, 4) = $ck;
106 substr ($corrupted, $page_size - 8, 4) = $ck;
107 }
108 syswrite(FILE, $corrupted);
109 close FILE;
110
111 # Change the flag offset of page 0 in doublewrite buffer
112 open(FILE, "+<", "$ENV{MYSQLD_DATADIR}ibdata1")||die "cannot open ibdata1\n";
113 sysseek(FILE, 6 * $page_size - 190, 0)||die "Unable to seek ibdata1\n";
114 sysread(FILE, $_, 12) == 12||die "Unable to read TRX_SYS\n";
115 my($magic,$d1,$d2)=unpack "NNN", $_;
116 die "magic=$magic, $d1, $d2\n" unless $magic == 536853855 && $d2 >= $d1 + 64;
117 sysseek(FILE, $d1 * $page_size, 0)||die "Unable to seek ibdata1\n";
118 # Find the page in the doublewrite buffer
119 for (my $d = $d1; $d < $d2 + 64; $d++)
120 {
121 sysread(FILE, $_, $page_size)==$page_size||die "Cannot read doublewrite\n";
122 next unless $_ eq $page;
123 sysseek(FILE, $d * $page_size, 0)||die "Unable to seek ibdata1\n";
124 # Write buggy FSP_SPACE_FLAGS to the doublewrite buffer for page
125 my $badflags = 0x0006FFFF;
126 substr ($_, 54, 4) = pack("N", $badflags);
127 if ($algo =~ /full_crc32/)
128 {
129 my $ck = mycrc32(substr($_, 0, $page_size - 4), 0, $polynomial);
130 substr($_, $page_size - 4, 4) = pack("N", $ck);
131 }
132 else
133 {
134 # Replace the innodb_checksum_algorithm=crc32 checksum
135 my $ck= pack("N",
136 mycrc32(substr($_, 4, 22), 0, $polynomial) ^
137 mycrc32(substr($_, 38, $page_size - 38 - 8), 0,
138 $polynomial));
139 substr ($_, 0, 4) = $ck;
140 substr ($_, $page_size - 8, 4) = $ck;
141 }
142 syswrite(FILE, $_, $page_size)==$page_size||die;
143 close(FILE);
144 exit 0;
145 }
146 die "Did not find the page in the doublewrite buffer ($d1,$d2)\n";
147 EOF
148
149 --source include/start_mysqld.inc
150 let SEARCH_PATTERN=InnoDB: Recovered page \\[page id: space=[1-9][0-9]*, page number=0\\];
151 --source include/search_pattern_in_file.inc
152 let SEARCH_PATTERN=InnoDB: The log was only scanned up to \\d+, while the current LSN at the time of the latest checkpoint \\d+ was 0 and the maximum LSN on a data page was 18446744073709551615!
153 --source include/search_pattern_in_file.inc
154 --error ER_XAER_NOTA
155 XA ROLLBACK 'x';
156 let $shutdown_timeout=0;
157 --source include/shutdown_mysqld.inc
158 let $shutdown_timeout=;
159 # Corrupt the file in a better way.
160
161 --remove_file $MYSQLD_DATADIR/ibdata1
162 --remove_file $MYSQLD_DATADIR/ib_logfile0
163 --move_file $MYSQLD_DATADIR/ibdata1.bak $MYSQLD_DATADIR/ibdata1
164 --move_file $MYSQLD_DATADIR/ib_logfile0.bak $MYSQLD_DATADIR/ib_logfile0
165
166 perl;
167 use IO::Handle;
168 my $fname= "$ENV{'MYSQLD_DATADIR'}test/t1.ibd";
169 my $page_size = $ENV{INNODB_PAGE_SIZE};
170 open(FILE, "+<", $fname) or die;
171 sysseek(FILE, ($page_size/2), 0);
172 syswrite(FILE, chr(0) x ($page_size/2));
173 sysseek(FILE, 3*$page_size, 0);
174 syswrite(FILE, chr(0) x ($page_size/2));
175 close FILE;
176 EOF
177 --source include/start_mysqld.inc
178 check table t1;
179 select f1, f2 from t1;
180
181 SET GLOBAL innodb_max_dirty_pages_pct_lwm=0,innodb_max_dirty_pages_pct=0;
182 let $wait_condition =
183 SELECT variable_value = 0
184 FROM information_schema.global_status
185 WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
186 --source include/wait_condition.inc
187 SET GLOBAL innodb_max_dirty_pages_pct=99;
188 --source ../include/no_checkpoint_start.inc
189 XA ROLLBACK 'x';
190 FLUSH TABLE t1 FOR EXPORT;
191
192 # If we are skipping the test at this point due to an unexpected
193 # checkpoint, we will already have tested a part of this functionality.
194 --let CLEANUP_IF_CHECKPOINT=drop table t1;
195 --source ../include/no_checkpoint_end.inc
196
197 # Zero out the first page in file and try to recover from dblwr
198 perl;
199 use IO::Handle;
200 open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/t1.ibd") or die;
201 syswrite(FILE, chr(0) x $ENV{INNODB_PAGE_SIZE});
202 close FILE;
203 EOF
204
205 --source include/start_mysqld.inc
206 let SEARCH_PATTERN=InnoDB: Recovered page \\[page id: space=[1-9][0-9]*, page number=[03]\\];
207 --source include/search_pattern_in_file.inc
208 check table t1;
209 select f1, f2 from t1;
210 drop table t1;
211
212 --echo # End of 10.5 tests