mirror of
https://github.com/MariaDB/server.git
synced 2025-04-26 11:49:09 +03:00
The error is caused by MDEV-30165 fix with the following commit: d13a57ae8181f2a8fbee86838d5476740e050d50 There is logical error in lock_release_on_prepare_try(): if (supremum_bit) lock_rec_unlock_supremum(*cell, lock); else lock_rec_dequeue_from_page(lock, false); Because there can be other bits set in the lock's bitmap, and the lock type can be suitable for releasing criteria, but the above logic releases only supremum bit of the lock. The fix is to release lock if it suits for releasing criteria and unlock supremum if supremum is locked otherwise. Tere is also the test for the case, which was reported by QA team. I placed it in a separate files, because it requires debug build. Reviewed by: Marko Mäkelä
49 lines
1.2 KiB
Plaintext
49 lines
1.2 KiB
Plaintext
--source include/have_innodb.inc
|
|
--source include/count_sessions.inc
|
|
|
|
CREATE TABLE t (
|
|
`a` INT NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
INSERT INTO t VALUES(10);
|
|
INSERT INTO t VALUES(20);
|
|
|
|
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
|
XA START '1';
|
|
SELECT * FROM t WHERE a > 20 FOR UPDATE;
|
|
# The following INSERT is necessary because trx_prepare() resets locks
|
|
# only if there were modifications in transaction.
|
|
INSERT INTO t VALUES(40);
|
|
XA END '1';
|
|
XA PREPARE '1';
|
|
|
|
connect (con1,localhost,root);
|
|
SET innodb_lock_wait_timeout=1;
|
|
# The following INSERT must not be blocked if XA PREPARE released supremum lock
|
|
INSERT INTO t VALUES(50);
|
|
|
|
--connection default
|
|
XA COMMIT '1';
|
|
|
|
XA START '1';
|
|
SELECT * FROM t WHERE a > 20 LOCK IN SHARE MODE;
|
|
# The following INSERT is necessary because trx_prepare() resets locks
|
|
# only if there were modifications in transaction.
|
|
INSERT INTO t VALUES (5);
|
|
XA END '1';
|
|
XA PREPARE '1';
|
|
|
|
--connection con1
|
|
# The following INSERT must not be blocked if XA PREPARE released supremum lock
|
|
INSERT INTO t VALUES (60);
|
|
# The following INSERT must not be blocked if XA PREPARE released shared lock
|
|
INSERT INTO t VALUES (30);
|
|
--disconnect con1
|
|
|
|
--connection default
|
|
XA COMMIT '1';
|
|
DROP TABLE t;
|
|
--source include/wait_until_count_sessions.inc
|