| 1 |
# This is a straightforward deadlock scenario. Since it involves more than |
| 2 |
# two processes, the main lock detector will find the problem and rollback |
| 3 |
# the session that first discovers it. Set deadlock_timeout in each session |
| 4 |
# so that it's predictable which session fails. |
| 5 |
|
| 6 |
setup |
| 7 |
{ |
| 8 |
CREATE TABLE a1 (); |
| 9 |
CREATE TABLE a2 (); |
| 10 |
CREATE TABLE a3 (); |
| 11 |
CREATE TABLE a4 (); |
| 12 |
CREATE TABLE a5 (); |
| 13 |
CREATE TABLE a6 (); |
| 14 |
CREATE TABLE a7 (); |
| 15 |
CREATE TABLE a8 (); |
| 16 |
} |
| 17 |
|
| 18 |
teardown |
| 19 |
{ |
| 20 |
DROP TABLE a1, a2, a3, a4, a5, a6, a7, a8; |
| 21 |
} |
| 22 |
|
| 23 |
session s1 |
| 24 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 25 |
step s1a1 { LOCK TABLE a1; } |
| 26 |
step s1a2 { LOCK TABLE a2; } |
| 27 |
step s1c { COMMIT; } |
| 28 |
|
| 29 |
session s2 |
| 30 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 31 |
step s2a2 { LOCK TABLE a2; } |
| 32 |
step s2a3 { LOCK TABLE a3; } |
| 33 |
step s2c { COMMIT; } |
| 34 |
|
| 35 |
session s3 |
| 36 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 37 |
step s3a3 { LOCK TABLE a3; } |
| 38 |
step s3a4 { LOCK TABLE a4; } |
| 39 |
step s3c { COMMIT; } |
| 40 |
|
| 41 |
session s4 |
| 42 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 43 |
step s4a4 { LOCK TABLE a4; } |
| 44 |
step s4a5 { LOCK TABLE a5; } |
| 45 |
step s4c { COMMIT; } |
| 46 |
|
| 47 |
session s5 |
| 48 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 49 |
step s5a5 { LOCK TABLE a5; } |
| 50 |
step s5a6 { LOCK TABLE a6; } |
| 51 |
step s5c { COMMIT; } |
| 52 |
|
| 53 |
session s6 |
| 54 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 55 |
step s6a6 { LOCK TABLE a6; } |
| 56 |
step s6a7 { LOCK TABLE a7; } |
| 57 |
step s6c { COMMIT; } |
| 58 |
|
| 59 |
session s7 |
| 60 |
setup { BEGIN; SET deadlock_timeout = '100s'; } |
| 61 |
step s7a7 { LOCK TABLE a7; } |
| 62 |
step s7a8 { LOCK TABLE a8; } |
| 63 |
step s7c { COMMIT; } |
| 64 |
|
| 65 |
session s8 |
| 66 |
setup { BEGIN; SET deadlock_timeout = '10ms'; } |
| 67 |
step s8a8 { LOCK TABLE a8; } |
| 68 |
step s8a1 { LOCK TABLE a1; } |
| 69 |
step s8c { COMMIT; } |
| 70 |
|
| 71 |
# Note: when s8a1 detects the deadlock and fails, s7a8 is released, making |
| 72 |
# it timing-dependent which query completion is received first by the tester. |
| 73 |
# To ensure output stability, add a blocking mark to force s8a1's completion |
| 74 |
# to be reported first. There is a second timing dependency, too: the tester |
| 75 |
# might or might not observe s8a1 during its short lock wait state. Apply a |
| 76 |
# dummy blocking mark to s8a1 to ensure it will be reported as "waiting" |
| 77 |
# regardless of that. |
| 78 |
|
| 79 |
permutation s1a1 s2a2 s3a3 s4a4 s5a5 s6a6 s7a7 s8a8 s1a2 s2a3 s3a4 s4a5 s5a6 s6a7 s7a8(s8a1) s8a1(*) s8c s7c s6c s5c s4c s3c s2c s1c |