| 1 |
--source include/have_debug_sync.inc |
| 2 |
--source include/count_sessions.inc |
| 3 |
|
| 4 |
# This test scenario exercises a rare case in which READ COMMITTED |
| 5 |
# (or UNCOMMITTED) transaction tries to release read locks during PREPARE stage |
| 6 |
# (as is typical for XA or in group replication) and is interupted MAX_FAILURES |
| 7 |
# times by other transactions when trying to iterate over its own list of locks. |
| 8 |
# The other transactions are converting implicit locks of the transaction to |
| 9 |
# explicit, adding the explicit locks to the list the transaction is iterating |
| 10 |
# over, so it has to restart. Finally the transaction gives up with s-latching |
| 11 |
# and attempts to x-latch the whole lock-sys to get job done. |
| 12 |
|
| 13 |
# keep in sync with MAX_FAILURES defined in lock_trx_release_read_locks() |
| 14 |
--let MAX_FAILURES=5 |
| 15 |
# We create one extra table |
| 16 |
--let i=0 |
| 17 |
while($i<=$MAX_FAILURES) |
| 18 |
{ |
| 19 |
--eval CREATE TABLE t$i (id INT PRIMARY KEY) ENGINE=InnoDB |
| 20 |
--inc $i |
| 21 |
} |
| 22 |
# We will need this row to create explicit lock on it from c0 |
| 23 |
INSERT INTO t0 (id) VALUES (1); |
| 24 |
|
| 25 |
--connect (c0, localhost, root,,) |
| 26 |
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; |
| 27 |
XA START 'x'; |
| 28 |
# create at least MAX_FAILURES implicit locks |
| 29 |
--let i=1 |
| 30 |
while($i<=$MAX_FAILURES) |
| 31 |
{ |
| 32 |
--eval INSERT INTO t$i (id) VALUES (1); |
| 33 |
--inc $i |
| 34 |
} |
| 35 |
# create at least 1 explicit lock |
| 36 |
SELECT * FROM t0 WHERE id=1 FOR UPDATE; |
| 37 |
XA END 'x'; |
| 38 |
SET DEBUG_SYNC='lock_trx_release_read_locks_in_x_mode_will_release |
| 39 |
SIGNAL c0_releases_in_xmode'; |
| 40 |
SET DEBUG_SYNC='try_relatch_trx_and_shard_and_do_noted_expected_version |
| 41 |
SIGNAL c0_noted_expected_version |
| 42 |
WAIT_FOR c0_can_go |
| 43 |
EXECUTE 5'; |
| 44 |
--send XA PREPARE 'x' |
| 45 |
|
| 46 |
--let i=1 |
| 47 |
while($i<=$MAX_FAILURES) |
| 48 |
{ |
| 49 |
--connect (c$i, localhost, root,,) |
| 50 |
BEGIN; |
| 51 |
SET DEBUG_SYNC = 'now WAIT_FOR c0_noted_expected_version'; |
| 52 |
--eval SET DEBUG_SYNC='lock_wait_will_wait SIGNAL c0_can_go' |
| 53 |
--send_eval SELECT * FROM t$i FOR SHARE |
| 54 |
|
| 55 |
--inc $i |
| 56 |
} |
| 57 |
|
| 58 |
--connection default |
| 59 |
SET DEBUG_SYNC='now WAIT_FOR c0_releases_in_xmode'; |
| 60 |
|
| 61 |
--connection c0 |
| 62 |
--reap |
| 63 |
XA COMMIT 'x'; |
| 64 |
|
| 65 |
--disconnect c0 |
| 66 |
--let i=1 |
| 67 |
while($i<=$MAX_FAILURES) |
| 68 |
{ |
| 69 |
--connection c$i |
| 70 |
--reap |
| 71 |
COMMIT; |
| 72 |
--connection default |
| 73 |
--disconnect c$i |
| 74 |
--inc $i |
| 75 |
} |
| 76 |
|
| 77 |
--let i=0 |
| 78 |
while($i<=$MAX_FAILURES) |
| 79 |
{ |
| 80 |
--eval DROP TABLE t$i |
| 81 |
--inc $i |
| 82 |
} |
| 83 |
|
| 84 |
--source include/wait_until_count_sessions.inc |