mariadb/mysql-test/suite/innodb/t/innodb_bug84958.test
2019-08-21 15:23:45 +03:00

93 lines
2.3 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
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency= 1;
DELIMITER ~~;
CREATE PROCEDURE insert_n(start int, end int)
BEGIN
DECLARE i INT DEFAULT start;
START TRANSACTION;
WHILE i <= end do
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = i;
SET i = i + 1;
END WHILE;
COMMIT;
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;
BEGIN;
SELECT * FROM t1;
--echo #
--echo # Create 100 newer record versions in con2 and con3
--echo #
connect (con2, localhost, root,,);
connection con2;
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;
--send CALL insert_n(51, 100);
connection con2;
reap;
connection con3;
reap;
INSERT INTO t1 VALUES (1, 2, 1) ON DUPLICATE KEY UPDATE c = NULL;
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=4
--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;
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
DROP TABLE t1;
DROP PROCEDURE insert_n;
DROP FUNCTION num_pages_get;