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 6setup 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 18teardown 19{ 20 DROP TABLE a1, a2, a3, a4, a5, a6, a7, a8; 21} 22 23session s1 24setup { BEGIN; SET deadlock_timeout = '100s'; } 25step s1a1 { LOCK TABLE a1; } 26step s1a2 { LOCK TABLE a2; } 27step s1c { COMMIT; } 28 29session s2 30setup { BEGIN; SET deadlock_timeout = '100s'; } 31step s2a2 { LOCK TABLE a2; } 32step s2a3 { LOCK TABLE a3; } 33step s2c { COMMIT; } 34 35session s3 36setup { BEGIN; SET deadlock_timeout = '100s'; } 37step s3a3 { LOCK TABLE a3; } 38step s3a4 { LOCK TABLE a4; } 39step s3c { COMMIT; } 40 41session s4 42setup { BEGIN; SET deadlock_timeout = '100s'; } 43step s4a4 { LOCK TABLE a4; } 44step s4a5 { LOCK TABLE a5; } 45step s4c { COMMIT; } 46 47session s5 48setup { BEGIN; SET deadlock_timeout = '100s'; } 49step s5a5 { LOCK TABLE a5; } 50step s5a6 { LOCK TABLE a6; } 51step s5c { COMMIT; } 52 53session s6 54setup { BEGIN; SET deadlock_timeout = '100s'; } 55step s6a6 { LOCK TABLE a6; } 56step s6a7 { LOCK TABLE a7; } 57step s6c { COMMIT; } 58 59session s7 60setup { BEGIN; SET deadlock_timeout = '100s'; } 61step s7a7 { LOCK TABLE a7; } 62step s7a8 { LOCK TABLE a8; } 63step s7c { COMMIT; } 64 65session s8 66setup { BEGIN; SET deadlock_timeout = '10ms'; } 67step s8a8 { LOCK TABLE a8; } 68step s8a1 { LOCK TABLE a1; } 69step 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 79permutation 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 80