mirror of
https://github.com/MariaDB/server.git
synced 2026-02-01 16:29:08 +01:00
Test was affected by incompletely closed preceding connections.
Make test agnostic to concurrent connections by querying
InnoDB status only for connections that it uses.
This is an addition to 3b2169f0d1, which didn't handle a case when
preceding test has active transaction on disconnect.
47 lines
1.5 KiB
Text
47 lines
1.5 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 $default_id= `select connection_id()`;
|
|
let $reg= /.*---TRANSACTION \d+, ACTIVE.*?(\d+ lock struct...), heap size \d+(, \d+ row lock...).*?\nMariaDB thread id $default_id,.*/\1\2/;
|
|
|
|
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 $reg
|
|
SHOW ENGINE INNODB STATUS;
|
|
ROLLBACK;
|
|
|
|
dec $isolation;
|
|
}
|
|
|
|
SET GLOBAL INNODB_STATUS_OUTPUT_LOCKS = @save_locks;
|
|
DROP TABLE t1;
|