mariadb/mysql-test/suite/innodb/t/gap_locks.test
Kristian Nielsen 3b2169f0d1 MDEV-37862: innodb.gap_locks test failure: 0 lock structs, 0 row locks
The test fails sporadically due to an insufficient --replace_regex.
The output of SHOW ENGINE INNODB STATUS can have some "not started"
transactions in additional to the "ACTIVE" transaction the test wants to
display, and the --replace_regex would wrongly pick one of the "not started"
transactions to show if it occured after the "ACTIVE" one in the output.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-01-02 10:19:38 +01:00

45 lines
1.4 KiB
Text

--source include/have_innodb.inc
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(40), c INT, INDEX(b,c))
ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,'1',1),(2,'2',1);
SET @save_locks= @@GLOBAL.innodb_status_output_locks;
SET GLOBAL INNODB_STATUS_OUTPUT_LOCKS = 'ON';
let $isolation= 4;
while ($isolation) {
let $tx_isolation= `SELECT CASE $isolation
WHEN 1 THEN 'READ UNCOMMITTED'
WHEN 2 THEN 'READ COMMITTED'
WHEN 3 THEN 'REPEATABLE READ'
ELSE 'SERIALIZABLE' END`;
eval SET TRANSACTION ISOLATION LEVEL $tx_isolation;
BEGIN;
DELETE FROM t1 WHERE b='2' AND c=2;
# The SHOW ENGINE INNODB STATUS looks like this:
#
# ...
# +LIST OF TRANSACTIONS FOR EACH SESSION:
# +---TRANSACTION (0x7f1e08168300), not started
# +0 lock struct(s), heap size 1144, 0 row lock(s)
# +---TRANSACTION (0x7f1e08167780), not started
# +0 lock struct(s), heap size 1144, 0 row lock(s)
# +---TRANSACTION 25, ACTIVE 0 sec
# +2 lock struct(s), heap size 1144, 1 row lock(s)
# ...
#
# We want the lock struct(s) and row lock(s) of the ACTIVE transaction, but
# not of any inactive ones. Note the use of non-greedy match ".*?", so that
# we get the values for the ACTIVE transaction, not the last values in the
# list.
--replace_regex /.*---TRANSACTION \d+, ACTIVE.*?(\d+ lock struct...), heap size \d+(, \d+ row lock...).*/\1\2/
SHOW ENGINE INNODB STATUS;
ROLLBACK;
dec $isolation;
}
SET GLOBAL INNODB_STATUS_OUTPUT_LOCKS = @save_locks;
DROP TABLE t1;