mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
4438ff07cd
Let us invoke wait_all_purged.inc right before the workload. Starting with MDEV-12288 in MariaDB Server 10.3, also INSERT generates purge workload. If we do not ensure that purge has run to completion, the results on 10.3 and later could be nondeterministic.
87 lines
2.1 KiB
Text
87 lines
2.1 KiB
Text
#
|
|
# Bug #84958 InnoDB's MVCC has O(N^2) behaviors
|
|
# https://bugs.mysql.com/bug.php?id=84958
|
|
#
|
|
# Set up the test with a procedure and a function.
|
|
#
|
|
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
|
SET GLOBAL innodb_purge_rseg_truncate_frequency= 1;
|
|
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~~
|
|
#
|
|
# Create a table with one record in it and start an RR transaction
|
|
#
|
|
CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY(a,b), KEY (b,c))
|
|
ENGINE=InnoDB;
|
|
BEGIN;
|
|
SELECT * FROM t1;
|
|
a b c
|
|
#
|
|
# Create 100 newer record versions in con2 and con3
|
|
#
|
|
connect con2, localhost, root,,;
|
|
connection con2;
|
|
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = NULL;
|
|
CALL insert_n(1, 50);;
|
|
connect con3, localhost, root,,;
|
|
connection con3;
|
|
CALL insert_n(51, 100);;
|
|
connection con2;
|
|
connection con3;
|
|
INSERT INTO t1 VALUES (1, 2, 1) ON DUPLICATE KEY UPDATE c = NULL;
|
|
connection default;
|
|
#
|
|
# Connect to default and record how many pages were accessed
|
|
# when selecting the record using the secondary key.
|
|
#
|
|
InnoDB 3 transactions not purged
|
|
SET @num_pages_1 = num_pages_get();
|
|
SELECT * FROM t1 force index (b);
|
|
a b c
|
|
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;
|
|
num_pages_diff
|
|
OK
|
|
#
|
|
# Commit and show the final record.
|
|
#
|
|
SELECT * FROM t1;
|
|
a b c
|
|
SELECT * FROM t1 force index (b);
|
|
a b c
|
|
COMMIT;
|
|
SELECT * FROM t1 force index (b);
|
|
a b c
|
|
1 2 NULL
|
|
SELECT * FROM t1;
|
|
a b c
|
|
1 2 NULL
|
|
CHECK TABLE t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 check status OK
|
|
#
|
|
# Cleanup
|
|
#
|
|
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;
|