Debian Codegraph @

mysql-test/suite/innodb/include/doublewrite_on_to_reduced.inc

raw
1 --let BACKUP=$MYSQL_TMP_DIR/datadir_backup
2 --let ORIG=$MYSQL_TMP_DIR/datadir_orig
3 if ($O_DIRECT) {
4 --let $restart_parameters = "restart: --datadir=$BACKUP/data --innodb-flush-method=O_DIRECT"
5 }
6
7 if (!$O_DIRECT) {
8 --let $restart_parameters = "restart: --datadir=$BACKUP/data"
9 }
10
11 --let $ERROR_LOG=$MYSQL_TMP_DIR/error.log
12
13 --disable_query_log
14 call mtr.add_suppression("Database page [0-9]+:1 contained only zeroes.");
15 call mtr.add_suppression("Header page consists of zero bytes");
16 call mtr.add_suppression("Checksum mismatch in datafile");
17 call mtr.add_suppression("but the innodb_page_size start-up parameter is");
18 call mtr.add_suppression("Database page corruption");
19 call mtr.add_suppression("Wrong server version");
20 --enable_query_log
21
22 --let INNODB_PAGE_SIZE=`select @@innodb_page_size`
23 --let MYSQLD_DATADIR=`select @@datadir`
24
25 --let $ARGS=--innodb_doublewrite=detect_only --log-error=$ERROR_LOG --datadir=$BACKUP/data
26
27 SHOW VARIABLES LIKE 'innodb_doublewrite';
28 SHOW VARIABLES LIKE 'innodb_fil_make_page_dirty_debug';
29 SHOW VARIABLES LIKE 'innodb_saved_page_number_debug';
30
31 --echo # Wait for purge to complete
32 --source include/wait_innodb_all_purged.inc
33
34 create table t1 (f1 int primary key, f2 blob) engine=innodb STATS_PERSISTENT=0;
35
36 START TRANSACTION;
37 INSERT INTO t1 VALUES(1, repeat('#',12));
38 INSERT INTO t1 VALUES(2, repeat('+',12));
39 INSERT INTO t1 VALUES(3, repeat('/',12));
40 INSERT INTO t1 VALUES(4, repeat('-',12));
41 INSERT INTO t1 VALUES(5, repeat('.',12));
42 COMMIT WORK;
43
44 # Slow shutdown and restart to make sure ibuf merge is finished
45 SET GLOBAL innodb_fast_shutdown = 0;
46 --source include/shutdown_mysqld.inc
47
48 --echo # Take backup of original datadir
49 --mkdir $BACKUP
50 --mkdir $ORIG
51 --force-cpdir $MYSQLD_DATADIR $BACKUP
52 --force-cpdir $MYSQLD_DATADIR $ORIG
53
54 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
55 --source include/start_mysqld.inc
56
57 --echo # ---------------------------------------------------------------
58 --echo # Test Begin: Test if recovery works if first page of user
59 --echo # tablespace is full of zeroes.
60
61 SHOW VARIABLES LIKE 'innodb_doublewrite';
62
63 --echo # Ensure that dirty pages of table t1 is flushed.
64 FLUSH TABLES t1 FOR EXPORT;
65 UNLOCK TABLES;
66
67 SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACEs
68 WHERE name = 'test/t1' INTO @space_id;
69
70 SET GLOBAL innodb_checkpoint_disabled=1;
71 SET GLOBAL innodb_limit_optimistic_insert_debug=2;
72
73 SELECT @@innodb_doublewrite;
74 BEGIN;
75 INSERT INTO t1 VALUES (6, repeat('%', 12));
76 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
77 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
78 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
79 COMMIT;
80
81 SET GLOBAL innodb_doublewrite=detect_only;
82 SELECT @@innodb_doublewrite;
83
84 BEGIN;
85 INSERT INTO t1 VALUES (0, repeat('%', 12));
86 INSERT INTO t1 SELECT f1+64,f2 FROM t1;
87
88 SET GLOBAL innodb_checkpoint_disabled = 1;
89
90 --echo # Make the first page dirty for table t1
91 SET GLOBAL innodb_saved_page_number_debug = 0;
92
93 --source include/expect_crash.inc
94 # Set the page dirty and force a flush to disk
95 --error CR_SERVER_LOST
96 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
97
98 --echo # Make the first page (page_no=0) of the user tablespace
99 --echo # full of zeroes.
100 --let IBD_FILE=$BACKUP/data/test/t1.ibd
101 --let PAGE_NUM="0"
102 --let ALL_ZEROES=1
103 --source corrupt_page.inc
104
105 --error 1,2,17,-2147483645
106 --exec $MYSQLD_CMD $ARGS
107
108 --let ABORT_ON=NOT_FOUND
109 --let SEARCH_PATTERN=Database page corruption of tablespace .*test.*t1.ibd space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
110 --let SEARCH_FILE= $ERROR_LOG
111 --source include/search_pattern_multiline.inc
112 --remove_file $ERROR_LOG
113
114 --echo # restoring original datadir
115 --force-rmdir $BACKUP/data
116 --force-cpdir $ORIG/data $BACKUP/data
117 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
118 --source include/start_mysqld.inc
119
120 --echo # Test End - 1
121
122 --echo # ---------------------------------------------------------------
123 --echo # Test Begin: Test if recovery works if first page of user
124 --echo # tablespace is corrupted.
125
126 SHOW VARIABLES LIKE 'innodb_doublewrite';
127
128 SELECT space from INFORMATION_SCHEMA.INNODB_TABLESPACES
129 WHERE name = 'test/t1' INTO @space_id;
130
131 --echo # Ensure that dirty pages of table t1 is flushed.
132 FLUSH TABLES t1 FOR EXPORT;
133 UNLOCK TABLES;
134
135 SET GLOBAL innodb_checkpoint_disabled=1;
136
137 SELECT @@innodb_doublewrite;
138 BEGIN;
139 INSERT INTO t1 VALUES (6, repeat('%', 12));
140 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
141 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
142 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
143 COMMIT;
144
145 SET GLOBAL innodb_doublewrite=detect_only;
146 SELECT @@innodb_doublewrite;
147
148 BEGIN;
149 INSERT INTO t1 VALUES (0, repeat('%', 12));
150
151 SET GLOBAL innodb_checkpoint_disabled = 1;
152
153 --echo # Make the first page dirty for table t1
154 SET GLOBAL innodb_saved_page_number_debug = 0;
155
156 --source include/expect_crash.inc
157 # Set the page dirty and force a flush to disk
158 --error CR_SERVER_LOST
159 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
160
161 --echo # Corrupt the first page (page_no=0) of the user tablespace.
162 --let IBD_FILE=$BACKUP/data/test/t1.ibd
163 --let PAGE_NUM="0"
164 --let ALL_ZEROES=0
165 --source corrupt_page.inc
166
167 --error 1,2,17,-2147483645
168 --exec $MYSQLD_CMD $ARGS
169
170 --let ABORT_ON=NOT_FOUND
171 --let SEARCH_PATTERN=Database page corruption of tablespace .*test.*t1.ibd space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
172 --let SEARCH_FILE= $ERROR_LOG
173 --source include/search_pattern_multiline.inc
174 --remove_file $ERROR_LOG
175
176 --echo # restoring original datadir
177 --force-rmdir $BACKUP/data
178 --force-cpdir $ORIG/data $BACKUP/data
179 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
180 --source include/start_mysqld.inc
181
182 --echo # Test End - 2
183 --echo # ---------------------------------------------------------------
184 --echo # Test Begin: Test if recovery works if 2nd page of user
185 --echo # tablespace is full of zeroes.
186
187 SHOW VARIABLES LIKE 'innodb_doublewrite';
188
189 SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
190 WHERE name = 'test/t1' INTO @space_id;
191
192 --echo # Ensure that dirty pages of table t1 is flushed.
193 FLUSH TABLES t1 FOR EXPORT;
194 UNLOCK TABLES;
195
196 SET GLOBAL innodb_checkpoint_disabled=1;
197
198 SELECT @@innodb_doublewrite;
199 BEGIN;
200 INSERT INTO t1 VALUES (6, repeat('%', 12));
201 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
202 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
203 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
204 COMMIT;
205
206 SET GLOBAL innodb_doublewrite=detect_only;
207 SELECT @@innodb_doublewrite;
208
209 BEGIN;
210 INSERT INTO t1 VALUES (0, repeat('%', 12));
211
212 SET GLOBAL innodb_checkpoint_disabled = 1;
213
214 --echo # Make the 2nd page dirty for table t1
215 SET GLOBAL innodb_saved_page_number_debug = 1;
216
217 # Set the page dirty and force a flush to disk
218 --source include/expect_crash.inc
219 --error CR_SERVER_LOST
220 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
221
222 --echo # Make the 2nd page (page_no=1) of the tablespace all zeroes.
223 --let IBD_FILE=$BACKUP/data/test/t1.ibd
224 --let PAGE_NUM=1
225 --let ALL_ZEROES=1
226 --source corrupt_page.inc
227
228 --error 1,2,17,-2147483645
229 --exec $MYSQLD_CMD $ARGS
230
231 --let ABORT_ON=NOT_FOUND
232 --let SEARCH_PATTERN=Database page corruption of tablespace .*test.*t1.ibd space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
233 --let SEARCH_FILE= $ERROR_LOG
234 --source include/search_pattern_multiline.inc
235 --remove_file $ERROR_LOG
236
237 --echo # restoring original datadir
238 --force-rmdir $BACKUP/data
239 --force-cpdir $ORIG/data $BACKUP/data
240 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
241 --source include/start_mysqld.inc
242
243 --echo # Test End - 3
244 --echo # ---------------------------------------------------------------
245 --echo # Test Begin: Test if recovery works if 2nd page of user
246 --echo # tablespace is corrupted.
247
248 SHOW VARIABLES LIKE 'innodb_doublewrite';
249
250 SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
251 WHERE name = 'test/t1' into @space_id;
252
253 #--echo # Ensure that dirty pages of table t1 is flushed.
254 FLUSH TABLES t1 FOR EXPORT;
255 UNLOCK TABLES;
256
257 SET GLOBAL innodb_checkpoint_disabled=1;
258
259 SELECT @@innodb_doublewrite;
260 BEGIN;
261 INSERT INTO t1 VALUES (6, repeat('%', 12));
262 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
263 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
264 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
265 COMMIT;
266
267 SET GLOBAL innodb_doublewrite=detect_only;
268 SELECT @@innodb_doublewrite;
269
270 BEGIN;
271 INSERT INTO t1 VALUES (0, repeat('%', 12));
272
273 --echo # Make the 2nd page dirty for table t1
274 SET GLOBAL innodb_saved_page_number_debug = 1;
275
276 SET GLOBAL innodb_checkpoint_disabled = 1;
277
278 --source include/expect_crash.inc
279 # Set the page dirty and force a flush to disk
280 --error CR_SERVER_LOST
281 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
282
283 --echo # Corrupt the 2nd page (page_no=1) of the user tablespace.
284 --let IBD_FILE=$BACKUP/data/test/t1.ibd
285 --let PAGE_NUM=1
286 --let ALL_ZEROES=0
287 --source corrupt_page.inc
288
289 --error 1,2,17,-2147483645
290 --exec $MYSQLD_CMD $ARGS
291
292 --let ABORT_ON=NOT_FOUND
293 --let SEARCH_PATTERN=Database page corruption of tablespace .*test.*t1.ibd space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
294 --let SEARCH_FILE= $ERROR_LOG
295 --source include/search_pattern_multiline.inc
296 --remove_file $ERROR_LOG
297
298 --echo # restoring original datadir
299 --force-rmdir $BACKUP/data
300 --force-cpdir $ORIG/data $BACKUP/data
301 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
302 --source include/start_mysqld.inc
303
304 --echo # Test End - 4
305 --echo # ---------------------------------------------------------------
306 --echo # Test Begin: Test if recovery works if first page of
307 --echo # system tablespace is full of zeroes.
308
309 SHOW VARIABLES LIKE 'innodb_doublewrite';
310
311 SET GLOBAL innodb_master_thread_disabled_debug=1;
312
313 SELECT @@innodb_doublewrite;
314 BEGIN;
315 INSERT INTO t1 VALUES (6, repeat('%', 12));
316 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
317 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
318 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
319 COMMIT;
320
321 SET GLOBAL innodb_doublewrite=detect_only;
322 SELECT @@innodb_doublewrite;
323
324 BEGIN;
325 INSERT INTO t1 VALUES (0, repeat('%', 12));
326
327 SET GLOBAL innodb_checkpoint_disabled = 1;
328
329 --echo # Make the first page dirty for system tablespace
330 SET GLOBAL innodb_saved_page_number_debug = 0;
331
332 # Set the page dirty and force a flush to disk
333 --source include/expect_crash.inc
334 --error CR_SERVER_LOST
335 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
336
337 --echo # Make the first page (page_no=0) of the system tablespace
338 --echo # all zeroes.
339 --let IBD_FILE=$BACKUP/data/ibdata1
340 --let PAGE_NUM="0"
341 --let ALL_ZEROES=1
342 --source corrupt_page.inc
343
344 --error 1,2,17,-2147483645
345 --exec $MYSQLD_CMD $ARGS
346
347 --let ABORT_ON=NOT_FOUND
348 --let SEARCH_PATTERN=Database page corruption of tablespace .*ibdata1 space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
349 --let SEARCH_FILE= $ERROR_LOG
350 --source include/search_pattern_multiline.inc
351 --remove_file $ERROR_LOG
352
353 --echo # restoring original datadir
354 --force-rmdir $BACKUP/data
355 --force-cpdir $ORIG/data $BACKUP/data
356 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
357 --source include/start_mysqld.inc
358
359 --echo # Test End - 5
360 --echo # ---------------------------------------------------------------
361 --echo # Test Begin: Test if recovery works if first page of
362 --echo # system tablespace is corrupted.
363
364 SHOW VARIABLES LIKE 'innodb_doublewrite';
365
366 SET GLOBAL innodb_master_thread_disabled_debug=1;
367
368 SELECT @@innodb_doublewrite;
369 BEGIN;
370 INSERT INTO t1 VALUES (6, repeat('%', 12));
371 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
372 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
373 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
374 COMMIT;
375
376 SET GLOBAL innodb_doublewrite=detect_only;
377 SELECT @@innodb_doublewrite;
378
379 BEGIN;
380 INSERT INTO t1 VALUES (0, repeat('%', 12));
381
382 SET GLOBAL innodb_checkpoint_disabled = 1;
383
384 --echo # Make the first page dirty for system tablespace
385 SET GLOBAL innodb_saved_page_number_debug = 0;
386
387 # Set the page dirty and force a flush to disk
388 --source include/expect_crash.inc
389 --error CR_SERVER_LOST
390 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
391
392 --echo # Corrupt the first page (page_no=0) of the system tablespace.
393 --let IBD_FILE=$BACKUP/data/ibdata1
394 --let PAGE_NUM="0"
395 --source corrupt_page.inc
396
397 --error 1,2,17,-2147483645
398 --exec $MYSQLD_CMD $ARGS
399
400 --let ABORT_ON=NOT_FOUND
401 --let SEARCH_PATTERN=Database page corruption of tablespace .*ibdata1 space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
402 --let SEARCH_FILE= $ERROR_LOG
403 --source include/search_pattern_multiline.inc
404 --remove_file $ERROR_LOG
405
406
407 --echo # restoring original datadir
408 --force-rmdir $BACKUP/data
409 --force-cpdir $ORIG/data $BACKUP/data
410 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
411 --source include/start_mysqld.inc
412
413 --echo # Test End - 6
414 --echo # ---------------------------------------------------------------
415 --echo # Test Begin: Test if recovery works if 2nd page of
416 --echo # system tablespace is full of zeroes.
417
418 SHOW VARIABLES LIKE 'innodb_doublewrite';
419
420 SET GLOBAL innodb_master_thread_disabled_debug=1;
421
422 SELECT @@innodb_doublewrite;
423 BEGIN;
424 INSERT INTO t1 VALUES (6, repeat('%', 12));
425 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
426 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
427 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
428 COMMIT;
429
430 SET GLOBAL innodb_doublewrite=detect_only;
431 SELECT @@innodb_doublewrite;
432
433 BEGIN;
434 INSERT INTO t1 VALUES (0, repeat('%', 12));
435
436 SET GLOBAL innodb_checkpoint_disabled = 1;
437
438 --echo # Make the second page dirty for system tablespace
439 SET GLOBAL innodb_saved_page_number_debug = 1;
440
441 # Set the page dirty and force a flush to disk
442 --source include/expect_crash.inc
443 --error CR_SERVER_LOST
444 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
445
446 --echo # Make the 2nd page (page_no=1) of the system tablespace
447 --echo # all zeroes.
448 --let IBD_FILE=$BACKUP/data/ibdata1
449 --let PAGE_NUM=1
450 --let ALL_ZEROES=1
451 --source corrupt_page.inc
452
453 --error 1,2,17,-2147483645
454 --exec $MYSQLD_CMD $ARGS
455
456 --let ABORT_ON=NOT_FOUND
457 --let SEARCH_PATTERN=Database page corruption of tablespace .*ibdata1 space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
458 --let SEARCH_FILE= $ERROR_LOG
459 --source include/search_pattern_multiline.inc
460 --remove_file $ERROR_LOG
461
462 --echo # restoring original datadir
463 --force-rmdir $BACKUP/data
464 --force-cpdir $ORIG/data $BACKUP/data
465 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
466 --source include/start_mysqld.inc
467
468 --echo # Test End - 7
469 --echo # ---------------------------------------------------------------
470 --echo # Test Begin: Test if recovery works if 2nd page of
471 --echo # system tablespace is corrupted.
472
473 SHOW VARIABLES LIKE 'innodb_doublewrite';
474
475 SET GLOBAL innodb_master_thread_disabled_debug=1;
476
477 SELECT @@innodb_doublewrite;
478 BEGIN;
479 INSERT INTO t1 VALUES (6, repeat('%', 12));
480 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
481 INSERT INTO t1 SELECT f1+16,f2 FROM t1;
482 INSERT INTO t1 SELECT f1+32,f2 FROM t1;
483 COMMIT;
484
485 SET GLOBAL innodb_doublewrite=detect_only;
486 SELECT @@innodb_doublewrite;
487
488 BEGIN;
489 INSERT INTO t1 VALUES (0, repeat('%', 12));
490
491 SET GLOBAL innodb_checkpoint_disabled = 1;
492
493 --echo # Make the second page dirty for system tablespace
494 SET GLOBAL innodb_saved_page_number_debug = 1;
495
496 # Set the page dirty and force a flush to disk
497 --source include/expect_crash.inc
498 --error CR_SERVER_LOST
499 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
500
501 --echo # Make the 2nd page (page_no=1) of the system tablespace
502 --echo # all zeroes.
503 --let IBD_FILE=$BACKUP/data/ibdata1
504 --let PAGE_NUM=1
505 --source corrupt_page.inc
506
507 --error 1,2,17,-2147483645
508 --exec $MYSQLD_CMD $ARGS
509
510 --let ABORT_ON=NOT_FOUND
511 --let SEARCH_PATTERN=Database page corruption of tablespace .*ibdata1 space_id: \d+ page_num: \d+. Cannot recover it from the doublewrite buffer because it was written in detect_only-doublewrite mode
512 --let SEARCH_FILE= $ERROR_LOG
513 --source include/search_pattern_multiline.inc
514 --remove_file $ERROR_LOG
515
516 --echo # restoring original datadir
517 --force-rmdir $BACKUP/data
518 --force-cpdir $ORIG/data $BACKUP/data
519
520 --let $restart_parameters =
521 --source include/start_mysqld.inc
522
523 --echo # Test End - 8
524 --echo # ---------------------------------------------------------------
525
526 DROP TABLE t1;
527 --force-rmdir $BACKUP
528 --force-rmdir $ORIG