| 1 |
# Scenario: |
| 2 |
# con1 acquires a shared lock |
| 3 |
# con2 wants an exclusive lock and has to wait |
| 4 |
# con3 wants a shared lock, and would have to wait for con2, |
| 5 |
# but con3 is a HP trx and does not want to wait, so it |
| 6 |
# jumps the queue, and gets the lock, and commits |
| 7 |
# con1 also commits |
| 8 |
# con2 should now acquire the lock and can commit |
| 9 |
|
| 10 |
--source include/have_debug_sync.inc |
| 11 |
|
| 12 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 13 |
INSERT INTO t1 VALUES (0); |
| 14 |
|
| 15 |
--connect(con1,localhost,root,,test) |
| 16 |
--connect(con2,localhost,root,,test) |
| 17 |
--connect(con3,localhost,root,,test) |
| 18 |
|
| 19 |
--connection con1 |
| 20 |
--echo # On connection 1 |
| 21 |
BEGIN; |
| 22 |
SELECT * FROM t1 WHERE c1=0 FOR SHARE; |
| 23 |
|
| 24 |
--connection con2 |
| 25 |
--echo # On connection 2 |
| 26 |
BEGIN; |
| 27 |
SET DEBUG_SYNC = 'lock_wait_will_wait SIGNAL con2_will_wait'; |
| 28 |
--send SELECT * FROM t1 WHERE c1=0 FOR UPDATE |
| 29 |
|
| 30 |
--connection con3 |
| 31 |
--echo # On connection 3 |
| 32 |
SET DEBUG_SYNC = 'now WAIT_FOR con2_will_wait'; |
| 33 |
--source include/start_transaction_high_prio.inc |
| 34 |
SELECT * FROM t1 WHERE c1=0 FOR SHARE; |
| 35 |
COMMIT; |
| 36 |
|
| 37 |
--connection con1 |
| 38 |
--echo # On connection 1 |
| 39 |
COMMIT; |
| 40 |
|
| 41 |
--connection con2 |
| 42 |
--echo # On connection 2 |
| 43 |
--reap |
| 44 |
COMMIT; |
| 45 |
|
| 46 |
--connection default |
| 47 |
--disconnect con1 |
| 48 |
--disconnect con2 |
| 49 |
--disconnect con3 |
| 50 |
|
| 51 |
DROP TABLE t1; |
| 52 |
|