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