Debian Codegraph @

mysql-test/suite/innodb/t/innodb_buffer_pool_load.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_load_at_startup=ON
7 # and innodb_buffer_pool_dump_at_shutdown=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 --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 let $check_cnt =
31 SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
32 WHERE table_name LIKE '%ib_bp_test%';
33
34 --let SPACE = `SELECT space FROM information_schema.innodb_tables WHERE name LIKE '%ib_bp_test%'`
35
36 # See that we have a small number of pages in the LRU
37 --eval $check_cnt
38
39 # Here we end up with 16382 rows in the table
40 --disable_query_log
41 INSERT INTO ib_bp_test (b, c) VALUES (REPEAT('b', 64), REPEAT('c', 256));
42 INSERT INTO ib_bp_test (b, c) VALUES (REPEAT('B', 64), REPEAT('C', 256));
43 let $i=12;
44 while ($i)
45 {
46 --eval INSERT INTO ib_bp_test (b, c) VALUES ($i, $i * $i);
47 INSERT INTO ib_bp_test (b, c) SELECT b, c FROM ib_bp_test;
48 dec $i;
49 }
50 --enable_query_log
51
52 # Accept 83 for 64k page size, 163 for 32k page size, 329 for 16k page size,
53 # 662 for 8k page size & 1392 for 4k page size
54 --replace_result 83 {checked_valid} 163 {checked_valid} 329 {checked_valid} 662 {checked_valid} 1392 {checked_valid}
55 --eval $check_cnt
56
57 --source include/shutdown_mysqld.inc
58
59 # Confirm the file has been created
60 --file_exists $file
61
62 # Add some garbage records to the dump file
63 --let IBDUMPFILE = $file
64 perl;
65 my $fn = $ENV{'IBDUMPFILE'};
66 open(my $fh, '>>', $fn) || die "perl open($fn): $!";
67 print $fh "123456,0\n";
68 print $fh "0,123456\n";
69 print $fh "123456,123456\n";
70 close($fh);
71 EOF
72
73 --source include/start_mysqld.inc
74
75 # Wait for the load to complete
76 --disable_warnings
77 let $wait_condition =
78 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) load completed at '
79 FROM performance_schema.global_status
80 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
81 --enable_warnings
82 --source include/wait_condition.inc
83
84 # Show the status, interesting if the above timed out
85 --disable_warnings
86 --replace_regex /^Buffer pool\(s\) load completed.*|^Loading buffer pool\(s\) from.*|^Loaded .* pages.*/Buffer pool load completed or still running/
87 SELECT variable_value
88 FROM performance_schema.global_status
89 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
90 --enable_warnings
91
92 # Accept 83 for 64k page size, 163 for 32k page size, 329 for 16k page size,
93 # 662 for 8k page size & 1392 for 4k page size
94 --replace_result 83 {checked_valid} 163 {checked_valid} 329 {checked_valid} 662 {checked_valid} 1392 {checked_valid}
95 --eval $check_cnt
96
97 call mtr.add_suppression("Error parsing");
98 --source include/shutdown_mysqld.inc
99
100 # Add some total garbage to the dump file
101 --let IBDUMPFILE = $file
102 perl;
103 my $fn = $ENV{'IBDUMPFILE'};
104 open(my $fh, '>>', $fn) || die "perl open($fn): $!";
105 print $fh "abcdefg\n";
106 close($fh);
107 EOF
108
109 --source include/start_mysqld.inc
110
111 # Wait for the load to fail
112 --disable_warnings
113 let $wait_condition =
114 SELECT SUBSTR(variable_value, 1, 13) = 'Error parsing'
115 FROM performance_schema.global_status
116 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
117 --enable_warnings
118 --source include/wait_condition.inc
119
120 --source include/shutdown_mysqld.inc
121
122 --echo # Re-write some valid pages to the dump file, make sure the space
123 --echo # should be valid but all the page no should be out of bound of the file
124 --let IBDUMPFILE = $file
125 perl;
126 my $fn = $ENV{'IBDUMPFILE'};
127 my $space = $ENV{'SPACE'};
128 open(my $fh, '>', $fn) || die "perl open($fn): $!";
129 print $fh "$space,10000\n";
130 print $fh "$space,10001\n";
131 print $fh "$space,10002\n";
132 close($fh);
133 EOF
134
135 --source include/start_mysqld.inc
136
137 # Wait for the load to complete
138 --disable_warnings
139 let $wait_condition =
140 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) load completed at '
141 FROM performance_schema.global_status
142 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
143 --enable_warnings
144 --source include/wait_condition.inc
145
146 # Show the status, interesting if the above timed out
147 --disable_warnings
148 --replace_regex /^Buffer pool\(s\) load completed.*|^Loading buffer pool\(s\) from.*|^Loaded .* pages.*/Buffer pool load completed or still running/
149 SELECT variable_value
150 FROM performance_schema.global_status
151 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
152 --enable_warnings
153
154 DROP TABLE ib_bp_test;
155 SET GLOBAL innodb_buffer_pool_dump_pct=default;
156
157 --echo #
158 --echo # Bug#22016556 INNODB LOOKS FOR BUFFER POOL FILE NAME IN '/' IF
159 --echo # INNODB_DATA_HOME_DIR IS EMPTY
160 --echo #
161
162 # Set different paths for --datadir
163 let $MYSQLD_DATADIR1 = $MYSQL_TMP_DIR/datadir1/data;
164
165 let $MYSQLD_BASEDIR= `select @@basedir`;
166
167 # Create custom datadir path
168 --mkdir $MYSQL_TMP_DIR/datadir1
169
170 let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/boot.sql;
171 let $start_page_size=`SELECT variable_value FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size'`;
172 # Create bootstrap file
173 write_file $BOOTSTRAP_SQL;
174 CREATE DATABASE test;
175 EOF
176
177 let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --lc_messages_dir=$MYSQL_SHAREDIR --innodb-data-home-dir= --innodb_data_file_path=$MYSQL_TMP_DIR/datadir1/ibdata:16M:autoextend --datadir=$MYSQLD_DATADIR1 --innodb_redo_log_capacity=30M --init-file=$BOOTSTRAP_SQL</dev/null>>$MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 --innodb-page-size=$start_page_size;
178
179 # Run the bootstrap command
180 --exec $NEW_CMD
181
182 # Start the DB server
183 --replace_result $MYSQLD_DATADIR1 MYSQLD_DATADIR1 $MYSQL_TMP_DIR MYSQL_TMP_DIR
184 --let $restart_parameters="restart: --innodb-data-home-dir= --innodb_data_file_path=$MYSQL_TMP_DIR/datadir1/ibdata:16M:autoextend --datadir=$MYSQLD_DATADIR1 --innodb_redo_log_capacity=30M"
185 --source include/restart_mysqld.inc
186
187 CREATE TABLE t1 (a int) ENGINE=innodb;
188 INSERT INTO t1 VALUES (1), (2), (3);
189
190 SET GLOBAL innodb_buffer_pool_dump_now=ON;
191
192 # Wait for the dump to complete
193 --disable_warnings
194 let $wait_condition =
195 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) dump completed at '
196 FROM performance_schema.global_status
197 WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status';
198 --enable_warnings
199 --source include/wait_condition.inc
200
201 --disable_warnings
202 --replace_regex /[0-9]{6}[[:space:]]+[0-9]{1,2}:[0-9]{2}:[0-9]{2}/TIMESTAMP_NOW/
203 SELECT variable_value
204 FROM performance_schema.global_status
205 WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status';
206 --enable_warnings
207
208 SET GLOBAL innodb_buffer_pool_load_now = ON;
209
210 # Wait for the load to complete
211 --disable_warnings
212 let $wait_condition =
213 SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) load completed at '
214 FROM performance_schema.global_status
215 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
216 --enable_warnings
217 --source include/wait_condition.inc
218
219 --disable_warnings
220 --replace_regex /^Buffer pool\(s\) load completed.*|^Loading buffer pool\(s\) from.*|^Loaded .* pages.*/Buffer pool load completed or still running/
221 SELECT variable_value
222 FROM performance_schema.global_status
223 WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
224 --enable_warnings
225
226 DROP TABLE t1;
227 DROP DATABASE test;
228
229 let $restart_parameters=;
230 --source include/restart_mysqld.inc
231
232 # Remove residue files and data folder
233 --force-rmdir $MYSQL_TMP_DIR/datadir1/
234 --remove_file $BOOTSTRAP_SQL
235 --remove_file $MYSQLTEST_VARDIR/tmp/bootstrap.log