Debian Codegraph @

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

raw
1 #
2 # Test for the functionality of InnoDB Buffer Pool dump/load.
3 #
4
5 # This case checks buffer pool dump/load works as expected
6 # with innodb_buffer_pool_dump_now=ON
7 # and innodb_buffer_pool_load_now=ON
8
9 # Skip this test from daily Valgrind execution
10 --source include/no_valgrind_without_big.inc
11
12 # Skip this test if page size is too big since buffer pool may not be
13 # large enough, especially if using multiple undo tablespaces.
14 --source include/have_innodb_max_16k.inc
15
16 # Skip this test if the test run is initialized with a non-default
17 # number of undo tablespaces.
18 --source include/have_innodb_default_undo_tablespaces.inc
19
20 --let $file = `SELECT CONCAT(@@datadir, @@global.innodb_buffer_pool_filename)`
21
22 --error 0,1
23 --remove_file $file
24
25 # Dump the whole buffer pool because if only a portion of it is dumped, we
26 # cannot be sure how many of the ib_bp_test's pages will end up in the dump.
27 SET GLOBAL innodb_buffer_pool_dump_pct=100;
28
29 # Create a table and populate it with some data
30 CREATE TABLE ib_bp_test
31 (a INT AUTO_INCREMENT, b VARCHAR(64), c TEXT, PRIMARY KEY (a), KEY (b, c(128)))
32 ENGINE=INNODB;
33
34 let $check_cnt =
35 SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
36 WHERE table_name LIKE '%ib_bp_test%';
37
38 --let SPACE = `SELECT space FROM information_schema.innodb_tables WHERE name LIKE '%ib_bp_test%'`
39
40 # See that we have a small number of pages in the LRU
41 --eval $check_cnt
42
43 # Here we end up with 16382 rows in the table
44 --disable_query_log
45 INSERT INTO ib_bp_test (b, c) VALUES (REPEAT('b', 64), REPEAT('c', 256));
46 INSERT INTO ib_bp_test (b, c) VALUES (REPEAT('B', 64), REPEAT('C', 256));
47 let $i=12;
48 while ($i)
49 {
50 --eval INSERT INTO ib_bp_test (b, c) VALUES ($i, $i * $i);
51 INSERT INTO ib_bp_test (b, c) SELECT b, c FROM ib_bp_test;
52 dec $i;
53 }
54 --enable_query_log
55
56 # Accept 83 for 64k page size, 163 for 32k page size, 329 for 16k page size,
57 # 662 for 8k page size & 1392 for 4k page size
58 --replace_result 83 {checked_valid} 163 {checked_valid} 329 {checked_valid} 662 {checked_valid} 1392 {checked_valid}
59 --eval $check_cnt
60
61 # Dump
62 SET GLOBAL innodb_buffer_pool_dump_now = ON;
63
64 # Wait for the dump to complete
65 --disable_warnings
66 let $wait_condition =
67 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) dump completed at '
68 FROM performance_schema.global_status
69 WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status';
70 --enable_warnings
71 --source include/wait_condition.inc
72
73 # Confirm the file has been created
74 --file_exists $file
75
76 # Add some garbage records to the dump file
77 --let IBDUMPFILE = $file
78 perl;
79 my $fn = $ENV{'IBDUMPFILE'};
80 open(my $fh, '>>', $fn) || die "perl open($fn): $!";
81 print $fh "123456,0\n";
82 print $fh "0,123456\n";
83 print $fh "123456,123456\n";
84 close($fh);
85 EOF
86
87 --move_file $file $file.now
88
89 --source include/shutdown_mysqld.inc
90
91 # Make sure no dump after shutdown
92 --error 1
93 --file_exists $file
94
95 --source include/start_mysqld.inc
96
97 --move_file $file.now $file
98
99 # See that we have no pages in the LRU
100 --eval $check_cnt
101
102 # Load the table so that entries in the I_S table do not appear as NULL
103 select count(*) from ib_bp_test where a = 1;
104
105 # Load
106 SET GLOBAL innodb_buffer_pool_load_now = ON;
107
108 # Wait for the load to complete
109 --disable_warnings
110 let $wait_condition =
111 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) load completed at '
112 FROM performance_schema.global_status
113 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
114 --enable_warnings
115 --source include/wait_condition.inc
116
117 # Show the status, interesting if the above timed out
118 --disable_warnings
119 --replace_regex /[0-9]{6}[[:space:]]+[0-9]{1,2}:[0-9]{2}:[0-9]{2}/TIMESTAMP_NOW/
120 SELECT variable_value
121 FROM performance_schema.global_status
122 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
123 --enable_warnings
124
125 # Accept 83 for 64k page size, 163 for 32k page size, 329 for 16k page size,
126 # 662 for 8k page size & 1392 for 4k page size
127 --replace_result 83 {checked_valid} 163 {checked_valid} 329 {checked_valid} 662 {checked_valid} 1392 {checked_valid}
128 --eval $check_cnt
129
130 # Add some total garbage to the dump file
131 --let IBDUMPFILE = $file
132 perl;
133 my $fn = $ENV{'IBDUMPFILE'};
134 open(my $fh, '>>', $fn) || die "perl open($fn): $!";
135 print $fh "abcdefg\n";
136 close($fh);
137 EOF
138
139 call mtr.add_suppression("Error parsing");
140
141 # Load
142 SET GLOBAL innodb_buffer_pool_load_now = ON;
143
144 # Wait for the load to fail
145 --disable_warnings
146 let $wait_condition =
147 SELECT SUBSTR(variable_value, 1, 13) = 'Error parsing'
148 FROM performance_schema.global_status
149 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
150 --enable_warnings
151 --source include/wait_condition.inc
152
153 --echo # Re-write some valid pages to the dump file, make sure the space
154 --echo # should be valid but all the page no should be out of bound of the file
155 --let IBDUMPFILE = $file
156 perl;
157 my $fn = $ENV{'IBDUMPFILE'};
158 my $space = $ENV{'SPACE'};
159 open(my $fh, '>', $fn) || die "perl open($fn): $!";
160 print $fh "$space,10000\n";
161 print $fh "$space,10001\n";
162 print $fh "$space,10002\n";
163 close($fh);
164 EOF
165
166 # We force the restart so that the table would be closed
167 --source include/restart_mysqld.inc
168
169 # Load directly, without accessing the table first
170 SET GLOBAL innodb_buffer_pool_load_now = ON;
171
172 # Wait for the load to complete
173 --disable_warnings
174 let $wait_condition =
175 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) load completed at '
176 FROM performance_schema.global_status
177 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
178 --enable_warnings
179 --source include/wait_condition.inc
180
181 # Show the status, interesting if the above timed out
182 --disable_warnings
183 --replace_regex /[0-9]{6}[[:space:]]+[0-9]{1,2}:[0-9]{2}:[0-9]{2}/TIMESTAMP_NOW/
184 SELECT variable_value
185 FROM performance_schema.global_status
186 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
187 --enable_warnings
188
189 DROP TABLE ib_bp_test;
190 SET GLOBAL innodb_buffer_pool_dump_pct=default;
191
192 --echo #
193 --echo # Bug#21371070 [ERROR] INNODB: CANNOT ALLOCATE 0 BYTES: SUCCESS
194 --echo #
195
196 --let $file = `SELECT CONCAT(@@datadir, @@global.innodb_buffer_pool_filename)`
197
198 # Remove the buffer pool file that exists already
199 --error 0,1
200 --remove_file $file
201
202 # Create an empty buffer pool file
203 write_file $file;
204 EOF
205
206 SET GLOBAL innodb_buffer_pool_load_now = ON;