mirror of
https://github.com/MariaDB/server.git
synced 2025-11-09 11:41:36 +03:00
The purpose of the change buffer was to reduce random disk access, which could be useful on rotational storage, but maybe less so on solid-state storage. When we wished to (1) insert a record into a non-unique secondary index, (2) delete-mark a secondary index record, (3) delete a secondary index record as part of purge (but not ROLLBACK), and the B-tree leaf page where the record belongs to is not in the buffer pool, we inserted a record into the change buffer B-tree, indexed by the page identifier. When the page was eventually read into the buffer pool, we looked up the change buffer B-tree for any modifications to the page, applied these upon the completion of the read operation. This was called the insert buffer merge. We remove the change buffer, because it has been the source of various hard-to-reproduce corruption bugs, including those fixed in commit5b9ee8d819and commit165564d3c3but not limited to them. A downgrade will fail with a clear message starting with commitdb14eb16f9(MDEV-30106). buf_page_t::state: Merge IBUF_EXIST to UNFIXED and WRITE_FIX_IBUF to WRITE_FIX. buf_pool_t::watch[]: Remove. trx_t: Move isolation_level, check_foreigns, check_unique_secondary, bulk_insert into the same bit-field. The only purpose of trx_t::check_unique_secondary is to enable bulk insert into an empty table. It no longer enables insert buffering for UNIQUE INDEX. btr_cur_t::thr: Remove. This field was originally needed for change buffering. Later, its use was extended to cover SPATIAL INDEX. Much of the time, rtr_info::thr holds this field. When it does not, we will add parameters to SPATIAL INDEX specific functions. ibuf_upgrade_needed(): Check if the change buffer needs to be updated. ibuf_upgrade(): Merge and upgrade the change buffer after all redo log has been applied. Free any pages consumed by the change buffer, and zero out the change buffer root page to mark the upgrade completed, and to prevent a downgrade to an earlier version. dict_load_tablespaces(): Renamed from dict_check_tablespaces_and_store_max_id(). This needs to be invoked before ibuf_upgrade(). btr_cur_open_at_rnd_pos(): Specialize for use in persistent statistics. The change buffer merge does not need this function anymore. btr_page_alloc(): Renamed from btr_page_alloc_low(). We no longer allocate any change buffer pages. btr_cur_open_at_rnd_pos(): Specialize for use in persistent statistics. The change buffer merge does not need this function anymore. row_search_index_entry(), btr_lift_page_up(): Add a parameter thr for the SPATIAL INDEX case. rtr_page_split_and_insert(): Specialized from btr_page_split_and_insert(). rtr_root_raise_and_insert(): Specialized from btr_root_raise_and_insert(). Note: The support for upgrading from the MySQL 3.23 or MySQL 4.0 change buffer format that predates the MySQL 4.1 introduction of the option innodb_file_per_table was removed in MySQL 5.6.5 as part of mysql/mysql-server@69b6241a79 and MariaDB 10.0.11 as part of1d0f70c2f8. In the tests innodb.log_upgrade and innodb.log_corruption, we create valid (upgraded) change buffer pages. Tested by: Matthias Leich
191 lines
5.4 KiB
Plaintext
191 lines
5.4 KiB
Plaintext
#Want to skip this test from daily Valgrind execution
|
|
--source include/no_valgrind_without_big.inc
|
|
#
|
|
# Test for the functionality of InnoDB Buffer Pool dump/load.
|
|
#
|
|
|
|
# This case checks buffer pool dump/load works as expected
|
|
# with innodb_buffer_pool_dump_now=ON
|
|
# and innodb_buffer_pool_load_now=ON
|
|
|
|
--source include/have_innodb.inc
|
|
# include/restart_mysqld.inc does not work in embedded mode
|
|
--source include/not_embedded.inc
|
|
--source include/have_sequence.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;
|
|
|
|
SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru
|
|
WHERE table_name = '`test`.`ib_bp_test`';
|
|
|
|
SELECT SPACE INTO @space FROM information_schema.innodb_buffer_page_lru
|
|
WHERE table_name = '`test`.`ib_bp_test`' AND PAGE_NUMBER=3;
|
|
|
|
let SPACE=`SELECT @space`;
|
|
|
|
INSERT INTO ib_bp_test
|
|
SELECT NULL, REPEAT('b', 64), REPEAT('c', 256) FROM seq_1_to_16382;
|
|
|
|
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
|
|
WHERE table_name = '`test`.`ib_bp_test`';
|
|
|
|
# Dump
|
|
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 information_schema.global_status
|
|
WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status';
|
|
--enable_warnings
|
|
--source include/wait_condition.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
|
|
|
|
--move_file $file $file.now
|
|
|
|
# Complete purge.
|
|
SET GLOBAL innodb_fast_shutdown=0;
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
# Make sure no dump after shutdown
|
|
--error 1
|
|
--file_exists $file
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
--move_file $file.now $file
|
|
|
|
# See that we have no pages in the LRU
|
|
SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru
|
|
WHERE table_name = '`test`.`ib_bp_test`';
|
|
|
|
# Load the table so that entries in the I_S table do not appear as NULL
|
|
select count(*) from ib_bp_test LIMIT 0;
|
|
|
|
# Load
|
|
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 information_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 /[0-9]{6}[[:space:]]+[0-9]{1,2}:[0-9]{2}:[0-9]{2}/TIMESTAMP_NOW/
|
|
SELECT variable_value
|
|
FROM information_schema.global_status
|
|
WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
|
|
--enable_warnings
|
|
|
|
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
|
|
WHERE table_name = '`test`.`ib_bp_test`';
|
|
|
|
# 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
|
|
|
|
call mtr.add_suppression("InnoDB: Error parsing");
|
|
|
|
# Load
|
|
SET GLOBAL innodb_buffer_pool_load_now = ON;
|
|
|
|
# Wait for the load to fail
|
|
--disable_warnings
|
|
let $wait_condition =
|
|
SELECT SUBSTR(variable_value, 1, 13) = 'Error parsing'
|
|
FROM information_schema.global_status
|
|
WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
|
|
--enable_warnings
|
|
--source include/wait_condition.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
|
|
|
|
# We force the restart so that the table would be closed
|
|
--source include/restart_mysqld.inc
|
|
|
|
# Load directly, without accessing the table first
|
|
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 information_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 /[0-9]{6}[[:space:]]+[0-9]{1,2}:[0-9]{2}:[0-9]{2}/TIMESTAMP_NOW/
|
|
SELECT variable_value
|
|
FROM information_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#21371070 [ERROR] INNODB: CANNOT ALLOCATE 0 BYTES: SUCCESS
|
|
--echo #
|
|
|
|
--let $file = `SELECT CONCAT(@@datadir, @@global.innodb_buffer_pool_filename)`
|
|
|
|
# Remove the buffer pool file that exists already
|
|
--error 0,1
|
|
--remove_file $file
|
|
|
|
# Create an empty buffer pool file
|
|
write_file $file;
|
|
EOF
|
|
|
|
SET GLOBAL innodb_buffer_pool_load_now = ON;
|