mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
14685b10df
The motivation of introducing the parameter innodb_purge_rseg_truncate_frequency in mysql/mysql-server@28bbd66ea5 and mysql/mysql-server@8fc2120fed seems to have been to avoid stalls due to freeing undo log pages or truncating undo log tablespaces. In MariaDB Server, innodb_undo_log_truncate=ON should be a much lighter operation than in MySQL, because it will not involve any log checkpoint. Another source of performance stalls should be trx_purge_truncate_rseg_history(), which is shrinking the history list by freeing the undo log pages whose undo records have been purged. To alleviate that, we will introduce a purge_truncation_task that will offload this from the purge_coordinator_task. In that way, the next innodb_purge_batch_size pages may be parsed and purged while the pages from the previous batch are being freed and the history list being shrunk. The processing of innodb_undo_log_truncate=ON will still remain the responsibility of the purge_coordinator_task. purge_coordinator_state::count: Remove. We will ignore innodb_purge_rseg_truncate_frequency, and act as if it had been set to 1 (the maximum shrinking frequency). purge_coordinator_state::do_purge(): Invoke an asynchronous task purge_truncation_callback() to free the undo log pages. purge_sys_t::iterator::free_history(): Free those undo log pages that have been processed. This used to be a part of trx_purge_truncate_history(). purge_sys_t::clone_end_view(): Take a new value of purge_sys.head as a parameter, so that it will be updated while holding exclusive purge_sys.latch. This is needed for race-free access to the field in purge_truncation_callback(). Reviewed by: Vladislav Lesin
93 lines
2.1 KiB
Text
93 lines
2.1 KiB
Text
--echo #
|
|
--echo # Bug #84958 InnoDB's MVCC has O(N^2) behaviors
|
|
--echo # https://bugs.mysql.com/bug.php?id=84958
|
|
--echo #
|
|
--echo # Set up the test with a procedure and a function.
|
|
--echo #
|
|
|
|
--source include/have_innodb.inc
|
|
|
|
DELIMITER ~~;
|
|
CREATE PROCEDURE insert_n(start int, end int)
|
|
BEGIN
|
|
DECLARE i INT DEFAULT start;
|
|
WHILE i <= end do
|
|
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = i;
|
|
SET i = i + 1;
|
|
END WHILE;
|
|
END~~
|
|
|
|
CREATE FUNCTION num_pages_get()
|
|
RETURNS INT
|
|
BEGIN
|
|
DECLARE ret INT;
|
|
SELECT variable_value INTO ret
|
|
FROM information_schema.global_status
|
|
WHERE variable_name = 'innodb_buffer_pool_read_requests';
|
|
RETURN ret;
|
|
END~~
|
|
DELIMITER ;~~
|
|
|
|
--echo #
|
|
--echo # Create a table with one record in it and start an RR transaction
|
|
--echo #
|
|
CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY(a,b), KEY (b,c))
|
|
ENGINE=InnoDB STATS_PERSISTENT=0;
|
|
--source include/wait_all_purged.inc
|
|
BEGIN;
|
|
SELECT * FROM t1;
|
|
|
|
--echo #
|
|
--echo # Create 100 newer record versions in con2 and con3
|
|
--echo #
|
|
connect (con2, localhost, root,,);
|
|
connection con2;
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = NULL;
|
|
--send CALL insert_n(1, 50);
|
|
|
|
connect (con3, localhost, root,,);
|
|
connection con3;
|
|
BEGIN;
|
|
--send CALL insert_n(51, 100);
|
|
|
|
connection con2;
|
|
reap;
|
|
COMMIT;
|
|
connection con3;
|
|
reap;
|
|
INSERT INTO t1 VALUES (1, 2, 1) ON DUPLICATE KEY UPDATE c = NULL;
|
|
COMMIT;
|
|
|
|
connection default;
|
|
|
|
--echo #
|
|
--echo # Connect to default and record how many pages were accessed
|
|
--echo # when selecting the record using the secondary key.
|
|
--echo #
|
|
--let $wait_all_purged=2
|
|
--source include/wait_all_purged.inc
|
|
SET @num_pages_1 = num_pages_get();
|
|
SELECT * FROM t1 force index (b);
|
|
SET @num_pages_2= num_pages_get();
|
|
|
|
SELECT IF(@num_pages_2 - @num_pages_1 < 5000, 'OK', @num_pages_2 - @num_pages_1) num_pages_diff;
|
|
|
|
--echo #
|
|
--echo # Commit and show the final record.
|
|
--echo #
|
|
SELECT * FROM t1;
|
|
SELECT * FROM t1 force index (b);
|
|
COMMIT;
|
|
SELECT * FROM t1 force index (b);
|
|
SELECT * FROM t1;
|
|
CHECK TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Cleanup
|
|
--echo #
|
|
disconnect con2;
|
|
disconnect con3;
|
|
DROP TABLE t1;
|
|
DROP PROCEDURE insert_n;
|
|
DROP FUNCTION num_pages_get;
|