Debian Codegraph @

mysql-test/suite/innodb/include/doublewrite_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: --innodb_doublewrite=detect_only --datadir=$BACKUP/data --innodb-flush-method=O_DIRECT"
5 }
6
7 if (!$O_DIRECT) {
8 --let $restart_parameters = "restart: --innodb_doublewrite=detect_only --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 --remove_files_wildcard $ORIG/data/ *.bdblwr
54 --remove_files_wildcard $ORIG/data/ *.dblwr
55
56 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
57 --source include/start_mysqld.inc
58
59 --echo # ---------------------------------------------------------------
60 --echo # Test Begin: Test if recovery works if first page of user
61 --echo # tablespace is full of zeroes.
62
63 SHOW VARIABLES LIKE 'innodb_doublewrite';
64
65 --echo # Ensure that dirty pages of table t1 is flushed.
66 FLUSH TABLES t1 FOR EXPORT;
67 UNLOCK TABLES;
68
69 SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACEs
70 WHERE name = 'test/t1' INTO @space_id;
71
72 SET GLOBAL innodb_checkpoint_disabled=1;
73 SET GLOBAL innodb_limit_optimistic_insert_debug=2;
74
75 BEGIN;
76 INSERT INTO t1 VALUES (6, repeat('%', 12));
77 INSERT INTO t1 SELECT f1+8,f2 FROM t1;
78
79 SET GLOBAL innodb_checkpoint_disabled = 1;
80
81 --echo # Make the first page dirty for table t1
82 SET GLOBAL innodb_saved_page_number_debug = 0;
83
84 --source include/expect_crash.inc
85 # Set the page dirty and force a flush to disk
86 --error CR_SERVER_LOST
87 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
88
89 --echo # Make the first page (page_no=0) of the user tablespace
90 --echo # full of zeroes.
91 --let IBD_FILE=$BACKUP/data/test/t1.ibd
92 --let PAGE_NUM="0"
93 --let ALL_ZEROES=1
94 --source corrupt_page.inc
95
96 --error 1,2,-2147483645
97 --exec $MYSQLD_CMD $ARGS
98
99 --let ABORT_ON=NOT_FOUND
100 --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
101 --let SEARCH_FILE= $ERROR_LOG
102 --source include/search_pattern_multiline.inc
103 --remove_file $ERROR_LOG
104
105 --echo # restoring original datadir
106 --force-rmdir $BACKUP/data
107 --force-cpdir $ORIG/data $BACKUP/data
108 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
109 --source include/start_mysqld.inc
110
111 --echo # Test End - 1
112 --echo # ---------------------------------------------------------------
113 --echo # Test Begin: Test if recovery works if first page of user
114 --echo # tablespace is corrupted.
115
116 SHOW VARIABLES LIKE 'innodb_doublewrite';
117
118 SELECT space from INFORMATION_SCHEMA.INNODB_TABLESPACES
119 WHERE name = 'test/t1' INTO @space_id;
120
121 --echo # Ensure that dirty pages of table t1 is flushed.
122 FLUSH TABLES t1 FOR EXPORT;
123 UNLOCK TABLES;
124
125 SET GLOBAL innodb_checkpoint_disabled=1;
126
127 BEGIN;
128 INSERT INTO t1 VALUES (6, repeat('%', 12));
129
130 SET GLOBAL innodb_checkpoint_disabled = 1;
131
132 --echo # Make the first page dirty for table t1
133 SET GLOBAL innodb_saved_page_number_debug = 0;
134
135 --source include/expect_crash.inc
136 # Set the page dirty and force a flush to disk
137 --error CR_SERVER_LOST
138 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
139
140 --echo # Corrupt the first page (page_no=0) of the user tablespace.
141 --let IBD_FILE=$BACKUP/data/test/t1.ibd
142 --let PAGE_NUM="0"
143 --let ALL_ZEROES=0
144 --source corrupt_page.inc
145
146 --error 1,2,-2147483645
147 --exec $MYSQLD_CMD $ARGS
148
149 --let ABORT_ON=NOT_FOUND
150 --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
151 --let SEARCH_FILE= $ERROR_LOG
152 --source include/search_pattern_multiline.inc
153 --remove_file $ERROR_LOG
154
155 --echo # restoring original datadir
156 --force-rmdir $BACKUP/data
157 --force-cpdir $ORIG/data $BACKUP/data
158 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
159 --source include/start_mysqld.inc
160
161 --echo # Test End - 2
162 --echo # ---------------------------------------------------------------
163 --echo # Test Begin: Test if recovery works if 2nd page of user
164 --echo # tablespace is full of zeroes.
165
166 SHOW VARIABLES LIKE 'innodb_doublewrite';
167
168 SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
169 WHERE name = 'test/t1' INTO @space_id;
170
171 --echo # Ensure that dirty pages of table t1 is flushed.
172 FLUSH TABLES t1 FOR EXPORT;
173 UNLOCK TABLES;
174
175 SET GLOBAL innodb_checkpoint_disabled=1;
176
177 BEGIN;
178 INSERT INTO t1 VALUES (6, repeat('%', 400));
179
180 SET GLOBAL innodb_checkpoint_disabled = 1;
181
182 --echo # Make the 2nd page dirty for table t1
183 SET GLOBAL innodb_saved_page_number_debug = 1;
184
185 # Set the page dirty and force a flush to disk
186 --source include/expect_crash.inc
187 --error CR_SERVER_LOST
188 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
189
190 --echo # Make the 2nd page (page_no=1) of the tablespace all zeroes.
191 --let IBD_FILE=$BACKUP/data/test/t1.ibd
192 --let PAGE_NUM=1
193 --let ALL_ZEROES=1
194 --source corrupt_page.inc
195
196 --error 1,2,-2147483645
197 --exec $MYSQLD_CMD $ARGS
198
199 --let ABORT_ON=NOT_FOUND
200 --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
201 --let SEARCH_FILE= $ERROR_LOG
202 --source include/search_pattern_multiline.inc
203 --remove_file $ERROR_LOG
204
205 --echo # restoring original datadir
206 --force-rmdir $BACKUP/data
207 --force-cpdir $ORIG/data $BACKUP/data
208 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
209 --source include/start_mysqld.inc
210
211 --echo # Test End - 3
212 --echo # ---------------------------------------------------------------
213 --echo # Test Begin: Test if recovery works if 2nd page of user
214 --echo # tablespace is corrupted.
215
216 SHOW VARIABLES LIKE 'innodb_doublewrite';
217
218 SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
219 WHERE name = 'test/t1' into @space_id;
220
221 #--echo # Ensure that dirty pages of table t1 is flushed.
222 FLUSH TABLES t1 FOR EXPORT;
223 UNLOCK TABLES;
224
225 SET GLOBAL innodb_checkpoint_disabled=1;
226
227 BEGIN;
228 INSERT INTO t1 VALUES (6, repeat('%', 400));
229
230 --echo # Make the 2nd page dirty for table t1
231 SET GLOBAL innodb_saved_page_number_debug = 1;
232
233 SET GLOBAL innodb_checkpoint_disabled = 1;
234
235 --source include/expect_crash.inc
236 # Set the page dirty and force a flush to disk
237 --error CR_SERVER_LOST
238 SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id;
239
240 --echo # Corrupt the 2nd page (page_no=1) of the user tablespace.
241 --let IBD_FILE=$BACKUP/data/test/t1.ibd
242 --let PAGE_NUM=1
243 --let ALL_ZEROES=0
244 --source corrupt_page.inc
245
246 --error 1,2,-2147483645
247 --exec $MYSQLD_CMD $ARGS
248
249 --let ABORT_ON=NOT_FOUND
250 --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
251 --let SEARCH_FILE= $ERROR_LOG
252 --source include/search_pattern_multiline.inc
253 --remove_file $ERROR_LOG
254
255 --echo # restoring original datadir
256 --force-rmdir $BACKUP/data
257 --force-cpdir $ORIG/data $BACKUP/data
258 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
259 --source include/start_mysqld.inc
260
261 --echo # Test End - 4
262 --echo # ---------------------------------------------------------------
263 --echo # Test Begin: Test if recovery works if first page of
264 --echo # system tablespace is full of zeroes.
265
266 SHOW VARIABLES LIKE 'innodb_doublewrite';
267
268 SET GLOBAL innodb_master_thread_disabled_debug=1;
269
270 BEGIN;
271 INSERT INTO t1 VALUES (6, repeat('%', 400));
272
273 SET GLOBAL innodb_checkpoint_disabled = 1;
274
275 --echo # Make the first page dirty for system tablespace
276 SET GLOBAL innodb_saved_page_number_debug = 0;
277
278 # Set the page dirty and force a flush to disk
279 --source include/expect_crash.inc
280 --error CR_SERVER_LOST
281 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
282
283 --echo # Make the first page (page_no=0) of the system tablespace
284 --echo # all zeroes.
285 --let IBD_FILE=$BACKUP/data/ibdata1
286 --let PAGE_NUM="0"
287 --let ALL_ZEROES=1
288 --source corrupt_page.inc
289
290 --error 1,2,-2147483645
291 --exec $MYSQLD_CMD $ARGS
292
293 --let ABORT_ON=NOT_FOUND
294 --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
295 --let SEARCH_FILE= $ERROR_LOG
296 --source include/search_pattern_multiline.inc
297 --remove_file $ERROR_LOG
298
299 --echo # restoring original datadir
300 --force-rmdir $BACKUP/data
301 --force-cpdir $ORIG/data $BACKUP/data
302 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
303 --source include/start_mysqld.inc
304
305 --echo # Test End - 5
306 --echo # ---------------------------------------------------------------
307 --echo # Test Begin: Test if recovery works if first page of
308 --echo # system tablespace is corrupted.
309
310 SHOW VARIABLES LIKE 'innodb_doublewrite';
311
312 SET GLOBAL innodb_master_thread_disabled_debug=1;
313
314 BEGIN;
315 INSERT INTO t1 VALUES (6, repeat('%', 400));
316
317 SET GLOBAL innodb_checkpoint_disabled = 1;
318
319 --echo # Make the first page dirty for system tablespace
320 SET GLOBAL innodb_saved_page_number_debug = 0;
321
322 # Set the page dirty and force a flush to disk
323 --source include/expect_crash.inc
324 --error CR_SERVER_LOST
325 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
326
327 --echo # Corrupt the first page (page_no=0) of the system tablespace.
328 --let IBD_FILE=$BACKUP/data/ibdata1
329 --let PAGE_NUM="0"
330 --source corrupt_page.inc
331
332 --error 1,2,-2147483645
333 --exec $MYSQLD_CMD $ARGS
334
335 --let ABORT_ON=NOT_FOUND
336 --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
337 --let SEARCH_FILE= $ERROR_LOG
338 --source include/search_pattern_multiline.inc
339 --remove_file $ERROR_LOG
340
341
342 --echo # restoring original datadir
343 --force-rmdir $BACKUP/data
344 --force-cpdir $ORIG/data $BACKUP/data
345 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
346 --source include/start_mysqld.inc
347
348 --echo # Test End - 6
349 --echo # ---------------------------------------------------------------
350 --echo # Test Begin: Test if recovery works if 2nd page of
351 --echo # system tablespace is full of zeroes.
352
353 SHOW VARIABLES LIKE 'innodb_doublewrite';
354
355 SET GLOBAL innodb_master_thread_disabled_debug=1;
356
357 BEGIN;
358 INSERT INTO t1 VALUES (6, repeat('%', 400));
359
360 SET GLOBAL innodb_checkpoint_disabled = 1;
361
362 --echo # Make the second page dirty for system tablespace
363 SET GLOBAL innodb_saved_page_number_debug = 1;
364
365 # Set the page dirty and force a flush to disk
366 --source include/expect_crash.inc
367 --error CR_SERVER_LOST
368 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
369
370 --echo # Make the 2nd page (page_no=1) of the system tablespace
371 --echo # all zeroes.
372 --let IBD_FILE=$BACKUP/data/ibdata1
373 --let PAGE_NUM=1
374 --let ALL_ZEROES=1
375 --source corrupt_page.inc
376
377 --error 1,2,-2147483645
378 --exec $MYSQLD_CMD $ARGS
379
380 --let ABORT_ON=NOT_FOUND
381 --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
382 --let SEARCH_FILE= $ERROR_LOG
383 --source include/search_pattern_multiline.inc
384 --remove_file $ERROR_LOG
385
386 --echo # restoring original datadir
387 --force-rmdir $BACKUP/data
388 --force-cpdir $ORIG/data $BACKUP/data
389 --replace_result $BACKUP BACKUP " --innodb-flush-method=O_DIRECT" ""
390 --source include/start_mysqld.inc
391
392 --echo # Test End - 7
393 --echo # ---------------------------------------------------------------
394 --echo # Test Begin: Test if recovery works if 2nd page of
395 --echo # system tablespace is corrupted.
396
397 SHOW VARIABLES LIKE 'innodb_doublewrite';
398
399 SET GLOBAL innodb_master_thread_disabled_debug=1;
400
401 BEGIN;
402 INSERT INTO t1 VALUES (6, repeat('%', 400));
403
404 SET GLOBAL innodb_checkpoint_disabled = 1;
405
406 --echo # Make the second page dirty for system tablespace
407 SET GLOBAL innodb_saved_page_number_debug = 1;
408
409 # Set the page dirty and force a flush to disk
410 --source include/expect_crash.inc
411 --error CR_SERVER_LOST
412 SET GLOBAL innodb_fil_make_page_dirty_debug = 0;
413
414 --echo # Make the 2nd page (page_no=1) of the system tablespace
415 --echo # all zeroes.
416 --let IBD_FILE=$BACKUP/data/ibdata1
417 --let PAGE_NUM=1
418 --source corrupt_page.inc
419
420 --error 1,2,-2147483645
421 --exec $MYSQLD_CMD $ARGS
422
423 --let ABORT_ON=NOT_FOUND
424 --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
425 --let SEARCH_FILE= $ERROR_LOG
426 --source include/search_pattern_multiline.inc
427 --remove_file $ERROR_LOG
428
429 --echo # restoring original datadir
430 --force-rmdir $BACKUP/data
431 --force-cpdir $ORIG/data $BACKUP/data
432
433 --let $restart_parameters =
434 --source include/start_mysqld.inc
435
436 --echo # Test End - 8
437 --echo # ---------------------------------------------------------------
438
439 DROP TABLE t1;
440 --force-rmdir $BACKUP
441 --force-rmdir $ORIG