Debian Codegraph @

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

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