mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-24738: Extend the test innodb.deadlock_detect
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
SET GLOBAL innodb_deadlock_detect=OFF;
|
||||
SET GLOBAL innodb_lock_wait_timeout=2;
|
||||
connection default;
|
||||
CREATE TABLE t1(
|
||||
id INT,
|
||||
@ -7,18 +5,20 @@ PRIMARY KEY(id)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(1), (2), (3);
|
||||
BEGIN;
|
||||
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
|
||||
SELECT * FROM t1 WHERE id = 1 LOCK IN SHARE MODE;
|
||||
connect con1,localhost,root,,;
|
||||
BEGIN;
|
||||
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
|
||||
SELECT * FROM t1 WHERE id = 2 LOCK IN SHARE MODE;
|
||||
connect con2,localhost,root,,;
|
||||
BEGIN;
|
||||
SELECT * FROM t1 WHERE id = 2 LOCK IN SHARE MODE;
|
||||
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
|
||||
connection default;
|
||||
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
|
||||
connection con1;
|
||||
connection con2;
|
||||
ROLLBACK;
|
||||
disconnect con2;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
ROLLBACK;
|
||||
DROP TABLE t1;
|
||||
disconnect con1;
|
||||
SET GLOBAL innodb_lock_wait_timeout=default;
|
||||
SET GLOBAL innodb_deadlock_detect=default;
|
||||
|
7
mysql-test/suite/innodb/t/deadlock_detect.combinations
Normal file
7
mysql-test/suite/innodb/t/deadlock_detect.combinations
Normal file
@ -0,0 +1,7 @@
|
||||
[OFF]
|
||||
--innodb-deadlock-detect=OFF
|
||||
--innodb-lock-wait-timeout=1
|
||||
|
||||
[ON]
|
||||
--innodb-deadlock-detect=ON
|
||||
--innodb-lock-wait-timeout=1
|
@ -3,11 +3,9 @@
|
||||
#
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/not_embedded.inc
|
||||
--source include/count_sessions.inc
|
||||
|
||||
SET GLOBAL innodb_deadlock_detect=OFF;
|
||||
SET GLOBAL innodb_lock_wait_timeout=2;
|
||||
let $have_deadlock=`select @@GLOBAL.innodb_deadlock_detect`;
|
||||
|
||||
connection default;
|
||||
|
||||
@ -22,24 +20,33 @@ INSERT INTO t1 VALUES(1), (2), (3);
|
||||
--disable_result_log
|
||||
BEGIN;
|
||||
|
||||
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
|
||||
SELECT * FROM t1 WHERE id = 1 LOCK IN SHARE MODE;
|
||||
|
||||
connect (con1,localhost,root,,);
|
||||
|
||||
BEGIN;
|
||||
SELECT * FROM t1 WHERE id = 2 LOCK IN SHARE MODE;
|
||||
|
||||
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
|
||||
connect (con2,localhost,root,,);
|
||||
BEGIN;
|
||||
SELECT * FROM t1 WHERE id = 2 LOCK IN SHARE MODE;
|
||||
|
||||
send SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
|
||||
|
||||
connection default;
|
||||
send SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
|
||||
|
||||
connection con1;
|
||||
connection con2;
|
||||
if (!$have_deadlock) {
|
||||
--error ER_LOCK_WAIT_TIMEOUT
|
||||
reap;
|
||||
|
||||
}
|
||||
if ($have_deadlock) {
|
||||
--error 0,ER_LOCK_DEADLOCK
|
||||
reap;
|
||||
}
|
||||
ROLLBACK;
|
||||
disconnect con2;
|
||||
disconnect con1;
|
||||
|
||||
#
|
||||
# Note here that con1 is the older transaction as it
|
||||
@ -50,8 +57,14 @@ ROLLBACK;
|
||||
# and does the update.
|
||||
#
|
||||
connection default;
|
||||
if (!$have_deadlock) {
|
||||
--error 0,ER_LOCK_WAIT_TIMEOUT
|
||||
reap;
|
||||
}
|
||||
if ($have_deadlock) {
|
||||
--error 0,ER_LOCK_DEADLOCK
|
||||
reap;
|
||||
}
|
||||
|
||||
ROLLBACK;
|
||||
|
||||
@ -59,9 +72,4 @@ ROLLBACK;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
disconnect con1;
|
||||
|
||||
--source include/wait_until_count_sessions.inc
|
||||
|
||||
SET GLOBAL innodb_lock_wait_timeout=default;
|
||||
SET GLOBAL innodb_deadlock_detect=default;
|
||||
|
Reference in New Issue
Block a user