Debian Codegraph @

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

raw
1 --source include/have_debug.inc
2 --source include/not_valgrind.inc
3
4 --echo #
5 --echo # WL#13775 - InnoDB: Encrypt DBLWR files
6 --echo #
7
8 --echo #
9 --echo # Test Begin: Test if recovery works if root page of user
10 --echo # table is full of zeroes. Valid copy of that page is there
11 --echo # in DBLWR file.
12 --echo #
13
14 CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 BLOB) ENCRYPTION='Y';
15
16 START TRANSACTION;
17 INSERT INTO t1 VALUES(1, repeat('#',12));
18 INSERT INTO t1 VALUES(2, repeat('+',12));
19 INSERT INTO t1 VALUES(3, repeat('/',12));
20 INSERT INTO t1 VALUES(4, repeat('-',12));
21 INSERT INTO t1 VALUES(5, repeat('.',12));
22 COMMIT WORK;
23
24 --echo # Wait for purge to complete
25 --source include/wait_innodb_all_purged.inc
26
27 --echo # Ensure that dirty pages of table t1 is flushed.
28 FLUSH TABLES t1 FOR EXPORT;
29 UNLOCK TABLES;
30
31 SET GLOBAL innodb_master_thread_disabled_debug=1;
32 SET GLOBAL innodb_checkpoint_disabled=1;
33
34 START TRANSACTION;
35 INSERT INTO t1 VALUES(6, repeat('.',12));
36
37 SET SESSION innodb_interpreter = 'init';
38 SET SESSION innodb_interpreter = 'open_table test/t1';
39
40 --echo # Identify the space_id of the given table.
41 SET SESSION innodb_interpreter = 'find_space_id test/t1';
42 SELECT @@session.innodb_interpreter_output INTO @space_id;
43
44 --echo # Find the root page number of the given table.
45 SET SESSION innodb_interpreter = 'find_root_page_no test/t1';
46 SELECT @@session.innodb_interpreter_output INTO @page_no;
47
48 --echo # Find the on-disk page type of the given page.
49 SET @cmd = CONCAT('find_ondisk_page_type ', @space_id, ' ', @page_no);
50 SET SESSION innodb_interpreter = @cmd;
51 SELECT @@session.innodb_interpreter_output INTO @page_type;
52 SELECT @page_type;
53
54 SET SESSION innodb_interpreter = 'find_tablespace_file_name test/t1';
55 SELECT @@session.innodb_interpreter_output INTO @space_file_name;
56
57 SET SESSION innodb_interpreter = 'find_tablespace_physical_page_size test/t1';
58 SELECT @@session.innodb_interpreter_output INTO @space_page_size;
59
60 SET SESSION innodb_interpreter = 'destroy';
61
62 let MYSQLD_DATADIR=`SELECT @@datadir`;
63 let PAGE_NO=`select @page_no`;
64 let FILE_NAME=`select @space_file_name`;
65 let PAGE_SIZE=`select @space_page_size`;
66
67 --source include/kill_mysqld.inc
68
69 --echo # Corrupt the root page of table t1 in the user tablespace.
70 perl;
71 use IO::Handle;
72 my $fname= "$ENV{'MYSQLD_DATADIR'}/$ENV{'FILE_NAME'}";
73 my $page_size = $ENV{'PAGE_SIZE'};
74 my $nbytes = $ENV{'PAGE_NO'} * $ENV{'PAGE_SIZE'};
75 open(FILE, "+<", $fname) or die;
76 FILE->autoflush(1);
77 binmode FILE;
78 seek(FILE, $nbytes, SEEK_SET);
79 print FILE chr(0) x $page_size;
80 close FILE;
81 EOF
82
83 --source include/start_mysqld.inc
84
85 SET SESSION innodb_interpreter = 'init';
86 SET SESSION innodb_interpreter = 'print_dblwr_has_encrypted_pages';
87 SET SESSION innodb_interpreter = 'destroy';
88
89 let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
90 let SEARCH_PATTERN= Double write file has encrypted pages;
91 --source include/search_pattern.inc
92
93 let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
94 let SEARCH_PATTERN= \\[Note\\] \\[MY-\\d+\\] \\[InnoDB\\] Recovered page \\[page id: space=\\d+, page number=\\d+\\] from the doublewrite buffer;
95 --source include/search_pattern.inc
96
97 CHECK TABLE t1;
98 SELECT f1, f2 FROM t1;
99
100 DROP TABLE t1;
101 --echo # Test End