Debian Codegraph @

mysql-test/suite/memcached/t/memc293_ibd2sdi.test

raw
1 --echo #
2 --echo # Test for IBD2SDI tool
3 --echo #
4
5 # Bug#20205934 - ENABLE VALGRIND FOR MEMCACHED TESTS
6 source include/not_valgrind.inc;
7 source include/have_memcached_plugin.inc;
8 # Memcached SDI APIs are enabled only for debug version
9 source include/have_debug.inc;
10 source include/have_ibd2sdi_debug.inc;
11
12 set global innodb_limit_optimistic_insert_debug = 2;
13
14
15 --disable_query_log
16 CALL mtr.add_suppression("daemon-memcached-w-batch-size': unsigned");
17 CALL mtr.add_suppression("Could not obtain server's UPN to be used as target service name");
18 CALL mtr.add_suppression("Warning: MySQL is trying to drop");
19 source include/memcache_config.inc;
20 --enable_query_log
21
22 INSERT INTO cache_policies VALUES('cache_policy', 'innodb_only',
23 'innodb_only', 'innodb_only', 'innodb_only');
24
25 INSERT INTO config_options VALUES('separator', '|');
26
27 # describe table for memcache
28 INSERT INTO containers VALUES ('desc_t1', 'test', 't1',
29 'c1', 'c2', '0', '0', '0', 'PRIMARY');
30
31 USE test;
32 --let MEMCACHED_PORT=11293
33 --let $MYSQLD_DATADIR= `SELECT @@datadir`
34 --let DUMP_FILE=$MYSQLTEST_VARDIR/log/ibd2sdi_out.txt
35 --let IBD_FILE=$MYSQLD_DATADIR/test/t1.ibd
36 --let IBD_PAGE_SIZE=`select @@innodb_page_size`
37
38 --echo # Case 1. Test with small SDI data
39 SET DEBUG = '+d, skip_sdi';
40 CREATE TABLE t1(c1 VARCHAR(32),
41 c2 TEXT,
42 primary key(c1))
43 ENGINE = INNODB;
44 SET DEBUG = '-d, skip_sdi';
45
46 # Tables must exist before plugin can be started!
47 --let $memcached_address=127.0.0.1:11293
48 --source ../include/load_daemon_memcached_expecting_success.inc
49
50 # Create SDI Indexes in the tablespace
51 let MEMCACHED_TABLE_MAPPING = desc_t1;
52
53 # Clear the current SDI in table
54 --source ../include/sdi_drop_index.inc
55 --source ../include/sdi_create_index.inc
56
57 SET GLOBAL innodb_buf_flush_list_now = ON;
58
59 # Test with Empty SDI
60 --exec $IBD2SDI $IBD_FILE 2>&1
61
62 # Insert into SDI tables via memcached
63 --source ../include/create_ibd2sdi_data.inc
64
65 # Shutdown server
66 --source include/shutdown_mysqld.inc
67
68 --source ../include/ibd2sdi_common.inc
69
70 # This should succeed with SDI pages
71 --exec $INNOCHECKSUM $IBD_FILE
72
73 --let restart_parameters=restart: --innodb_checksum_algorithm=innodb
74 --source include/start_mysqld.inc
75 --let $memcached_check_attempts=20
76 --let $memcached_expect=success
77 --source ../include/check_daemon_memcached.inc
78
79 INSERT INTO innodb_memcache.containers VALUES ('desc_t2', 'test', 't2',
80 'c1', 'c2', '0', '0', '0', 'PRIMARY');
81
82 --echo # test with innodb checksum
83 SET DEBUG = '+d, skip_sdi';
84 CREATE TABLE t2(c1 VARCHAR(32),
85 c2 TEXT,
86 primary key(c1)) ENGINE=INNODB;
87 SET DEBUG = '-d, skip_sdi';
88
89 # Insert into SDI tables via memcached
90 let MEMCACHED_TABLE_MAPPING = desc_t2;
91 --let IBD_FILE=$MYSQLD_DATADIR/test/t2.ibd
92
93 # Clear the current SDI in table
94 --source ../include/sdi_drop_index.inc
95 --source ../include/sdi_create_index.inc
96
97 --source ../include/create_ibd2sdi_data.inc
98
99 # Shutdown server
100 --source include/shutdown_mysqld.inc
101
102 --exec $IBD2SDI --skip-pretty $IBD_FILE -c innodb 2>&1
103
104 --let restart_parameters=restart: --innodb_checksum_algorithm=none
105 --source include/start_mysqld.inc
106 --let $memcached_check_attempts=20
107 --let $memcached_expect=success
108 --source ../include/check_daemon_memcached.inc
109 --let restart_parameters=
110 SET DEBUG = '+d, skip_sdi';
111 DROP TABLE t2;
112 SET DEBUG = '-d, skip_sdi';
113
114 INSERT INTO innodb_memcache.containers VALUES ('desc_t3', 'test', 't3',
115 'c1', 'c2', '0', '0', '0', 'PRIMARY');
116
117 --echo # test with none checksum
118 SET DEBUG = '+d, skip_sdi';
119 CREATE TABLE t3(c1 VARCHAR(32),
120 c2 TEXT,
121 primary key(c1)) ENGINE=INNODB;
122 SET DEBUG = '-d, skip_sdi';
123
124 # Insert into SDI tables via memcached
125 let MEMCACHED_TABLE_MAPPING = desc_t3;
126 --let IBD_FILE=$MYSQLD_DATADIR/test/t3.ibd
127
128 # Clear the current SDI in table
129 --source ../include/sdi_drop_index.inc
130 --source ../include/sdi_create_index.inc
131
132 --source ../include/create_ibd2sdi_data.inc
133
134 # Shutdown server
135 --source include/shutdown_mysqld.inc
136
137 --exec $IBD2SDI --skip-pretty $IBD_FILE --strict-check=none 2>&1
138
139 --let IBD_FILE=$MYSQLD_DATADIR/test/t1.ibd
140
141 --error 1
142 --exec $IBD2SDI --debug=d,ib_tmp_file_fail $IBD_FILE -d $MYSQL_TMP_DIR/out.txt 2>&1
143 --remove_files_wildcard $MYSQL_TMP_DIR/ ib_sdi*
144
145 ## header contains version/platform information
146 --replace_result $IBD2SDI IBD2SDI
147 # see: Bug #29525890 REPLACE_REGEX DOLAR DOES NOT MATCH END OF LINE WITH EXEC
148 --replace_regex / Ver [0-9].*\n?$// /(Copyright \(c\)) [0-9]+, [0-9]+(.*)/\1 YEAR, YEAR\2/
149 --error 1
150 --exec $IBD2SDI 2>&1
151 --replace_regex /descriptor [0-9]*/descriptor X/
152 --error 1
153 --exec $IBD2SDI --debug=d,ib_seek_error $IBD_FILE 2>&1
154
155 --error 1
156 --exec $IBD2SDI --debug=d,ib_invalid_page $IBD_FILE 2>&1
157
158 --error 1
159 --exec $IBD2SDI --debug=d,ib_file_open_error $IBD_FILE 2>&1
160
161 --exec $IBD2SDI --skip-pretty --debug=d,ib_partial_page $IBD_FILE 2>&1
162
163 --error 1
164 --exec $IBD2SDI --debug=d,ib_no_sdi $IBD_FILE 2>&1
165
166 # searching non-existent id & type
167 --exec $IBD2SDI -t 2 -i 2 $IBD_FILE 2>&1
168
169 --echo # 18. Corrupt Root page numbers in Page 1
170 --echo # We should still see data because of the good
171 --echo # page numbers in Page 2
172
173 --copy_file $IBD_FILE $MYSQLD_DATADIR/test/t1.ibd.backup
174 --let IBD_CHAR = 0
175 --let IBD_PAGE_NO = 1
176 --let IBD_OFFSET = 26
177 --let IBD_CHAR_LEN= 8
178 --source include/corrupt_ibd2sdi.inc
179
180 --exec $IBD2SDI --skip-pretty $IBD_FILE 2>&1
181
182 # Restore original copy
183 --remove_file $IBD_FILE
184 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
185
186 --echo # 19. Test with broken node-page link. The child page_no
187 --echo # will be zero. Use --no-checksum as the page is corrupted.
188
189 --let IBD_PAGE_NO = 3
190 # 137 = PAGE_NEW_INFIMUM(99) + next_rec_offset(27) + ID_LEN(8) +
191 # TYPE_LEN(4)
192 --let IBD_OFFSET = 137
193 --let IBD_CHAR_LEN= 4
194 --source include/corrupt_ibd2sdi.inc
195
196 --replace_regex /into file.*\./into file: FILENAME/
197 --error 1
198 --exec $IBD2SDI --skip-pretty -n $IBD_FILE 2>&1
199
200 # Restore original copy
201 --remove_file $IBD_FILE
202 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
203
204 --echo # 20. Test with broken leaf-page link. The child page_no
205 --echo # will be zero. Use --no-checksum as the page is corrupted
206 # FIL_PAGE_NEXT = 12
207
208 --let IBD_CHAR = 0
209 --let IBD_PAGE_NO = 10
210 --let IBD_OFFSET = 12
211 --let IBD_CHAR_LEN= 4
212 --source include/corrupt_ibd2sdi.inc
213
214 --replace_regex /into file.*\./into file: FILENAME/
215 --error 1
216 --exec $IBD2SDI --skip-pretty -n $IBD_FILE 2>&1
217
218 --echo # Retrieve from .ibd file
219 --replace_regex /space=[0-9]*/space=X/
220 --error 1
221 --exec $IBD2SDI --skip-pretty $IBD_FILE 2>&1
222
223 # Restore original copy
224 --remove_file $IBD_FILE
225 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
226
227 --echo # 21. Test with Leaf Page full of Zeros
228 --echo # Checksum will be valid. Skip checksum is not necessary
229 --let IBD_CHAR = 0
230 --let IBD_PAGE_NO = 10
231 --let IBD_OFFSET = 0
232 --let IBD_CHAR_LEN= $IBD_PAGE_SIZE
233 --source include/corrupt_ibd2sdi.inc
234
235 --replace_regex /into file.*\./into file: FILENAME/
236 --error 1
237 --exec $IBD2SDI --skip-pretty $IBD_FILE 2>&1
238
239 # Restore original copy
240 --remove_file $IBD_FILE
241 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
242
243 --echo # 22. Test with Record corruption. User record pointing to
244 --echo # INFIMUM Causing INFINITE loops.
245 --let IBD_PAGE_NO = 10
246 --let IBD_OFFSET = 124
247
248 # On page at the rec (position 126, next rec will be read from
249 # position 124, We write offset such that it points to INFIMIUM
250 # which at 99th byte from page origin. So at 124th byte, we need to write
251 # (99-126) = -27 in big endian format at next_rec_offset position
252 # (i.e. at 124). In big endian, it would 0x10000-0x1b(27) = 65509
253 --let IBD_CHAR = 65509
254 --let IBD_CHAR_LEN= 2
255 --source include/corrupt_ibd2sdi.inc
256
257 --replace_regex /into file.*\./into file: FILENAME/
258 --error 1
259 --exec $IBD2SDI --skip-pretty $IBD_FILE -n -d $DUMP_FILE 2>&1
260 --cat_file $DUMP_FILE
261
262 # Restore original copy
263 --remove_file $IBD_FILE
264 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
265
266 --echo # 23. Test with INFIMUM payload corruption. We should just
267 --echo # see a msg in error log but data retrieval should be OK
268 --let IBD_PAGE_NO = 10
269 --let IBD_CHAR = 0
270 --let IBD_OFFSET = 99
271 --let IBD_CHAR_LEN = 4
272 --source include/corrupt_ibd2sdi.inc
273
274 --exec $IBD2SDI --skip-pretty $IBD_FILE -n -d $DUMP_FILE 2>&1
275 --cat_file $DUMP_FILE
276
277 # Restore original copy
278 --remove_file $IBD_FILE
279 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
280
281 --echo # 24. Test with SUPREMUM payload corruption. We should just
282 --echo # see a msg in error log but data retrieval should be OK
283 --let IBD_PAGE_NO = 7
284 --let IBD_CHAR = 0
285 --let IBD_OFFSET = 112
286 --let IBD_CHAR_LEN = 4
287 --source include/corrupt_ibd2sdi.inc
288
289 --exec $IBD2SDI --skip-pretty $IBD_FILE -n -d $DUMP_FILE 2>&1
290 --cat_file $DUMP_FILE
291
292 # Restore original copy
293 --remove_file $IBD_FILE
294 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
295
296 --echo # 25. Test with SUPREMUM next-rec offset corruption. We should just
297 --echo # see a msg in error log but data retrieval should be OK
298 --let IBD_PAGE_NO = 6
299 --let IBD_CHAR = 20
300 --let IBD_CHAR_LEN = 2
301 --let IBD_OFFSET = 110
302 --source include/corrupt_ibd2sdi.inc
303
304 --exec $IBD2SDI --skip-pretty $IBD_FILE -n -d $DUMP_FILE 2>&1
305 --cat_file $DUMP_FILE
306
307 # Restore original copy
308 --remove_file $IBD_FILE
309 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
310
311 --echo # 26. Test with SPACE FLAGS Corruption
312 --let IBD_PAGE_NO = "0"
313 --let IBD_CHAR = 512
314 --let IBD_CHAR_LEN = 4
315 --let IBD_OFFSET = 54
316 --source include/corrupt_ibd2sdi.inc
317
318 --exec $IBD2SDI --skip-pretty $IBD_FILE -n -d $DUMP_FILE 2>&1
319 --cat_file $DUMP_FILE
320
321 # Restore original copy
322 --remove_file $IBD_FILE
323 --copy_file $MYSQLD_DATADIR/test/t1.ibd.backup $IBD_FILE
324
325 --source include/start_mysqld.inc
326 --let $memcached_check_attempts=20
327 --let $memcached_expect=success
328 --source ../include/check_daemon_memcached.inc
329
330 # Clean up
331 SET DEBUG = '+d, skip_sdi';
332 DROP TABLE t1;
333 SET DEBUG = '-d, skip_sdi';
334
335 SET GLOBAL innodb_limit_optimistic_insert_debug = default;
336 --let SKIP_LARGE_DATA_FILE = > $MYSQLTEST_VARDIR/log/large_ibd2sdi.err
337
338 --echo # Case 2: Insert large SDI in uncompressed table
339 SET DEBUG = '+d, skip_sdi';
340 CREATE TABLE t1(c1 VARCHAR(32),
341 c2 TEXT,
342 primary key(c1))
343 ENGINE = INNODB;
344 SET DEBUG = '-d, skip_sdi';
345
346 let MEMCACHED_TABLE_MAPPING = desc_t1;
347 # Clear the current SDI in table
348 --source ../include/sdi_drop_index.inc
349 --source ../include/sdi_create_index.inc
350
351 # Insert into SDI tables via memcached
352 --source ../include/create_ibd2sdi_data_large.inc
353
354 # Shutdown server
355 --source include/shutdown_mysqld.inc
356
357 --echo # Section I: Test options
358 --source ../include/ibd2sdi_common.inc
359
360 # Start server
361 --source include/start_mysqld.inc
362 --let $memcached_check_attempts=20
363 --let $memcached_expect=success
364 --source ../include/check_daemon_memcached.inc
365
366 SET DEBUG = '+d, skip_sdi';
367 DROP TABLE t1;
368 SET DEBUG = '-d, skip_sdi';
369
370 --echo # Case 3: Insert large SDI in compressed table
371
372 SET DEBUG = '+d, skip_sdi';
373 CREATE TABLE t1(c1 VARCHAR(32),
374 c2 TEXT,
375 primary key(c1))
376 ENGINE = INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
377 SET DEBUG = '-d, skip_sdi';
378
379 let MEMCACHED_TABLE_MAPPING = desc_t1;
380 # Clear the current SDI in table
381 --source ../include/sdi_drop_index.inc
382 --source ../include/sdi_create_index.inc
383
384 # Insert into SDI tables via memcached
385 --source ../include/create_ibd2sdi_data_large.inc
386
387 # Shutdown server
388 --source include/shutdown_mysqld.inc
389
390 --echo # Section I: Test options
391 --source ../include/ibd2sdi_common.inc
392
393 # Start server
394 --source include/start_mysqld.inc
395 --let $memcached_check_attempts=20
396 --let $memcached_expect=success
397 --source ../include/check_daemon_memcached.inc
398
399 SET DEBUG = '+d, skip_sdi';
400 DROP TABLE t1;
401 SET DEBUG = '-d, skip_sdi';
402
403 --echo # Case 3: Insert large SDI in compressed table
404
405 SET DEBUG = '+d, skip_sdi';
406 CREATE TABLE t1(c1 VARCHAR(32),
407 c2 TEXT,
408 primary key(c1))
409 ENGINE = INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
410 SET DEBUG = '-d, skip_sdi';
411
412 let MEMCACHED_TABLE_MAPPING = desc_t1;
413 # Clear the current SDI in table
414 --source ../include/sdi_drop_index.inc
415 --source ../include/sdi_create_index.inc
416
417 # Insert into SDI tables via memcached
418 --source ../include/create_ibd2sdi_data_large.inc
419
420 # Shutdown server
421 --source include/shutdown_mysqld.inc
422
423 --echo # Section I: Test options
424 --source ../include/ibd2sdi_common.inc
425
426 --replace_regex /space=[0-9]*/space=X/ /.*page_zip_decompress/page_zip_decompress/
427 --error 1
428 --exec $IBD2SDI --debug=d,ib_decompress_fail $IBD_FILE 2>&1
429
430 --exec $INNOCHECKSUM $IBD_FILE -D $MYSQL_TMP_DIR/out.txt
431 --remove_file $MYSQL_TMP_DIR/out.txt
432
433 # Start server
434 --source include/start_mysqld.inc
435 --let $memcached_check_attempts=20
436 --let $memcached_expect=success
437 --source ../include/check_daemon_memcached.inc
438
439 SET DEBUG = '+d, skip_sdi';
440 DROP TABLE t1;
441 SET DEBUG = '-d, skip_sdi';
442
443 --echo # Case 4: Insert large SDI in General Tablespace
444
445 --let IBD_FILE=$MYSQLD_DATADIR/ts1.ibd
446 SET DEBUG = '+d, skip_sdi';
447 CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd';
448 CREATE TABLE t1(c1 VARCHAR(32),
449 c2 TEXT,
450 primary key(c1))
451 ENGINE = INNODB TABLESPACE=ts1;
452 SET DEBUG = '-d, skip_sdi';
453
454 let MEMCACHED_TABLE_MAPPING = desc_t1;
455 # Clear the current SDI in table
456 --source ../include/sdi_drop_index.inc
457 --source ../include/sdi_create_index.inc
458
459 # Insert into SDI tables via memcached
460 --source ../include/create_ibd2sdi_data_large.inc
461
462 # Shutdown server
463 --source include/shutdown_mysqld.inc
464
465 --echo # Section I: Test options
466 --source ../include/ibd2sdi_common.inc
467
468 # Start server
469 --source include/start_mysqld.inc
470 --let $memcached_check_attempts=20
471 --let $memcached_expect=success
472 --source ../include/check_daemon_memcached.inc
473
474 SET DEBUG = '+d, skip_sdi';
475 DROP TABLE t1;
476 DROP TABLESPACE ts1;
477 SET DEBUG = '-d, skip_sdi';
478
479 # Stop plugin before innodb_memcached configuration
480 UNINSTALL PLUGIN daemon_memcached;
481
482 DROP DATABASE innodb_memcache;
483 SET GLOBAL transaction_isolation = default;
484 SET DEBUG = '+d, skip_sdi';
485 DROP TABLE t3;
486 SET DEBUG = '-d, skip_sdi';
487 --remove_file $DUMP_FILE
488 --remove_file $MYSQLTEST_VARDIR/log/large_ibd2sdi.err
489 --remove_file $MYSQLD_DATADIR/test/t1.ibd.backup