Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c9864b

Browse files
committed
Add some isolation tests for deadlock detection and resolution.
Previously, we had no test coverage for the deadlock detector.
1 parent38f8bdc commit4c9864b

File tree

9 files changed

+261
-0
lines changed

9 files changed

+261
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Parsed test spec with 8 sessions
2+
3+
starting permutation: s1a1 s2a2 s3a3 s4a4 s5a5 s6a6 s7a7 s8a8 s1a2 s2a3 s3a4 s4a5 s5a6 s6a7 s7a8 s8a1 s8c s7c s6c s5c s4c s3c s2c s1c
4+
step s1a1: LOCK TABLE a1;
5+
step s2a2: LOCK TABLE a2;
6+
step s3a3: LOCK TABLE a3;
7+
step s4a4: LOCK TABLE a4;
8+
step s5a5: LOCK TABLE a5;
9+
step s6a6: LOCK TABLE a6;
10+
step s7a7: LOCK TABLE a7;
11+
step s8a8: LOCK TABLE a8;
12+
step s1a2: LOCK TABLE a2; <waiting ...>
13+
step s2a3: LOCK TABLE a3; <waiting ...>
14+
step s3a4: LOCK TABLE a4; <waiting ...>
15+
step s4a5: LOCK TABLE a5; <waiting ...>
16+
step s5a6: LOCK TABLE a6; <waiting ...>
17+
step s6a7: LOCK TABLE a7; <waiting ...>
18+
step s7a8: LOCK TABLE a8; <waiting ...>
19+
step s8a1: LOCK TABLE a1;
20+
step s7a8: <... completed>
21+
error in steps s8a1 s7a8: ERROR: deadlock detected
22+
step s8c: COMMIT;
23+
step s7c: COMMIT;
24+
step s6a7: <... completed>
25+
step s6c: COMMIT;
26+
step s5a6: <... completed>
27+
step s5c: COMMIT;
28+
step s4a5: <... completed>
29+
step s4c: COMMIT;
30+
step s3a4: <... completed>
31+
step s3c: COMMIT;
32+
step s2a3: <... completed>
33+
step s2c: COMMIT;
34+
step s1a2: <... completed>
35+
step s1c: COMMIT;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s1as s2as s1ae s2ae s1c s2c
4+
step s1as: LOCK TABLE a1 IN ACCESS SHARE MODE;
5+
step s2as: LOCK TABLE a1 IN ACCESS SHARE MODE;
6+
step s1ae: LOCK TABLE a1 IN ACCESS EXCLUSIVE MODE; <waiting ...>
7+
step s2ae: LOCK TABLE a1 IN ACCESS EXCLUSIVE MODE;
8+
step s1ae: <... completed>
9+
error in steps s2ae s1ae: ERROR: deadlock detected
10+
step s1c: COMMIT;
11+
step s2c: COMMIT;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Parsed test spec with 4 sessions
2+
3+
starting permutation: s1a s2a s2b s3a s4a s1b s1c s2c s3c s4c
4+
step s1a: LOCK TABLE a1 IN SHARE UPDATE EXCLUSIVE MODE;
5+
step s2a: LOCK TABLE a2 IN ACCESS SHARE MODE;
6+
step s2b: LOCK TABLE a1 IN SHARE UPDATE EXCLUSIVE MODE; <waiting ...>
7+
step s3a: LOCK TABLE a2 IN ACCESS EXCLUSIVE MODE; <waiting ...>
8+
step s4a: LOCK TABLE a2 IN ACCESS EXCLUSIVE MODE; <waiting ...>
9+
step s1b: LOCK TABLE a2 IN SHARE UPDATE EXCLUSIVE MODE; <waiting ...>
10+
step s1b: <... completed>
11+
step s1c: COMMIT;
12+
step s2b: <... completed>
13+
step s2c: COMMIT;
14+
step s3a: <... completed>
15+
step s3c: COMMIT;
16+
step s4a: <... completed>
17+
step s4c: COMMIT;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Parsed test spec with 4 sessions
2+
3+
starting permutation: d1a1 d2a2 e1l e2l d1a2 d2a1 d1c e1c d2c e2c
4+
step d1a1: LOCK TABLE a1 IN ACCESS SHARE MODE;
5+
step d2a2: LOCK TABLE a2 IN ACCESS SHARE MODE;
6+
step e1l: LOCK TABLE a1 IN ACCESS EXCLUSIVE MODE; <waiting ...>
7+
step e2l: LOCK TABLE a2 IN ACCESS EXCLUSIVE MODE; <waiting ...>
8+
step d1a2: LOCK TABLE a2 IN ACCESS SHARE MODE; <waiting ...>
9+
step d2a1: LOCK TABLE a1 IN ACCESS SHARE MODE; <waiting ...>
10+
step d1a2: <... completed>
11+
step d1c: COMMIT;
12+
step e1l: <... completed>
13+
step e1c: COMMIT;
14+
step d2a1: <... completed>
15+
step d2c: COMMIT;
16+
step e2l: <... completed>
17+
step e2c: COMMIT;

‎src/test/isolation/isolation_schedule

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ test: partial-index
1010
test: two-ids
1111
test: multiple-row-versions
1212
test: index-only-scan
13+
test: deadlock-simple
14+
test: deadlock-hard
15+
test: deadlock-soft
16+
test: deadlock-soft-2
1317
test: fk-contention
1418
test: fk-deadlock
1519
test: fk-deadlock2
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This is a straightforward deadlock scenario. Since it involves more than
2+
# two processes, the mainlock detector will find the problem and rollback the
3+
# backend which discovers it.
4+
5+
setup
6+
{
7+
CREATETABLEa1 ();
8+
CREATETABLEa2 ();
9+
CREATETABLEa3 ();
10+
CREATETABLEa4 ();
11+
CREATETABLEa5 ();
12+
CREATETABLEa6 ();
13+
CREATETABLEa7 ();
14+
CREATETABLEa8 ();
15+
}
16+
17+
teardown
18+
{
19+
DROPTABLEa1,a2,a3,a4,a5,a6,a7,a8;
20+
}
21+
22+
session"s1"
23+
setup{BEGIN;SETdeadlock_timeout='10s'; }
24+
step"s1a1"{LOCKTABLEa1; }
25+
step"s1a2"{LOCKTABLEa2; }
26+
step"s1c"{COMMIT; }
27+
28+
session"s2"
29+
setup{BEGIN;SETdeadlock_timeout='10s'; }
30+
step"s2a2"{LOCKTABLEa2; }
31+
step"s2a3"{LOCKTABLEa3; }
32+
step"s2c"{COMMIT; }
33+
34+
session"s3"
35+
setup{BEGIN;SETdeadlock_timeout='10s'; }
36+
step"s3a3"{LOCKTABLEa3; }
37+
step"s3a4"{LOCKTABLEa4; }
38+
step"s3c"{COMMIT; }
39+
40+
session"s4"
41+
setup{BEGIN;SETdeadlock_timeout='10s'; }
42+
step"s4a4"{LOCKTABLEa4; }
43+
step"s4a5"{LOCKTABLEa5; }
44+
step"s4c"{COMMIT; }
45+
46+
session"s5"
47+
setup{BEGIN;SETdeadlock_timeout='10s'; }
48+
step"s5a5"{LOCKTABLEa5; }
49+
step"s5a6"{LOCKTABLEa6; }
50+
step"s5c"{COMMIT; }
51+
52+
session"s6"
53+
setup{BEGIN;SETdeadlock_timeout='10s'; }
54+
step"s6a6"{LOCKTABLEa6; }
55+
step"s6a7"{LOCKTABLEa7; }
56+
step"s6c"{COMMIT; }
57+
58+
session"s7"
59+
setup{BEGIN;SETdeadlock_timeout='10s'; }
60+
step"s7a7"{LOCKTABLEa7; }
61+
step"s7a8"{LOCKTABLEa8; }
62+
step"s7c"{COMMIT; }
63+
64+
session"s8"
65+
setup{BEGIN;SETdeadlock_timeout='10ms'; }
66+
step"s8a8"{LOCKTABLEa8; }
67+
step"s8a1"{LOCKTABLEa1; }
68+
step"s8c"{COMMIT; }
69+
70+
permutation"s1a1""s2a2""s3a3""s4a4""s5a5""s6a6""s7a7""s8a8""s1a2""s2a3""s3a4""s4a5""s5a6""s6a7""s7a8""s8a1""s8c""s7c""s6c""s5c""s4c""s3c""s2c""s1c"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The deadlock detector has a special case for "simple" deadlocks. A simple
2+
# deadlock occurs when we attempt a lock upgrade while another process waits
3+
# for a lock upgrade on the same object; and the sought locks conflict with
4+
# those already held, so that neither process can complete its upgrade until
5+
# the other releases locks. Test this scenario.
6+
7+
setup
8+
{
9+
CREATETABLEa1();
10+
}
11+
12+
teardown
13+
{
14+
DROPTABLEa1;
15+
}
16+
17+
session"s1"
18+
setup{ BEGIN;}
19+
step"s1as"{LOCKTABLEa1INACCESSSHAREMODE;}
20+
step"s1ae"{LOCKTABLEa1INACCESSEXCLUSIVEMODE;}
21+
step"s1c"{COMMIT;}
22+
23+
session"s2"
24+
setup{ BEGIN;}
25+
step"s2as"{LOCKTABLEa1INACCESSSHAREMODE;}
26+
step"s2ae"{LOCKTABLEa1INACCESSEXCLUSIVEMODE;}
27+
step"s2c"{COMMIT;}
28+
29+
permutation"s1as""s2as""s1ae""s2ae""s1c""s2c"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Soft deadlock requiring reversal of multiple wait-edges. s1 must
2+
# jump over both s3 and s4 and acquire the lock on a2 immediately,
3+
# since s3 and s4 are hard-blocked on a1.
4+
5+
setup
6+
{
7+
CREATETABLEa1 ();
8+
CREATETABLEa2 ();
9+
}
10+
11+
teardown
12+
{
13+
DROPTABLEa1,a2;
14+
}
15+
16+
session"s1"
17+
setup{BEGIN; }
18+
step"s1a"{LOCKTABLEa1INSHAREUPDATEEXCLUSIVEMODE; }
19+
step"s1b"{LOCKTABLEa2INSHAREUPDATEEXCLUSIVEMODE; }
20+
step"s1c"{COMMIT; }
21+
22+
session"s2"
23+
setup{BEGIN; }
24+
step"s2a" {LOCKTABLEa2INACCESSSHAREMODE; }
25+
step"s2b" {LOCKTABLEa1INSHAREUPDATEEXCLUSIVEMODE; }
26+
step"s2c"{COMMIT; }
27+
28+
session"s3"
29+
setup{BEGIN; }
30+
step"s3a"{LOCKTABLEa2INACCESSEXCLUSIVEMODE; }
31+
step"s3c"{COMMIT; }
32+
33+
session"s4"
34+
setup{BEGIN; }
35+
step"s4a"{LOCKTABLEa2INACCESSEXCLUSIVEMODE; }
36+
step"s4c"{COMMIT; }
37+
38+
permutation"s1a""s2a""s2b""s3a""s4a""s1b""s1c""s2c""s3c""s4c"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Four-process deadlock with two hard edges and two soft edges.
2+
# d2 waits for e1 (soft edge), e1 waits for d1 (hard edge),
3+
# d1 waits for e2 (soft edge), e2 waits for d2 (hard edge).
4+
# The deadlock detector resolves the deadlock by reversing the d1-e2 edge,
5+
# unblocking d1.
6+
7+
setup
8+
{
9+
CREATETABLEa1 ();
10+
CREATETABLEa2 ();
11+
}
12+
13+
teardown
14+
{
15+
DROPTABLEa1,a2;
16+
}
17+
18+
session"d1"
19+
setup{BEGIN;SETdeadlock_timeout='10s'; }
20+
step"d1a1"{LOCKTABLEa1INACCESSSHAREMODE; }
21+
step"d1a2"{LOCKTABLEa2INACCESSSHAREMODE; }
22+
step"d1c"{COMMIT; }
23+
24+
session"d2"
25+
setup{BEGIN;SETdeadlock_timeout='10ms'; }
26+
step"d2a2"{LOCKTABLEa2INACCESSSHAREMODE; }
27+
step"d2a1"{LOCKTABLEa1INACCESSSHAREMODE; }
28+
step"d2c"{COMMIT; }
29+
30+
session"e1"
31+
setup{BEGIN;SETdeadlock_timeout='10s'; }
32+
step"e1l"{LOCKTABLEa1INACCESSEXCLUSIVEMODE; }
33+
step"e1c"{COMMIT; }
34+
35+
session"e2"
36+
setup{BEGIN;SETdeadlock_timeout='10s'; }
37+
step"e2l"{LOCKTABLEa2INACCESSEXCLUSIVEMODE; }
38+
step"e2c"{COMMIT; }
39+
40+
permutation"d1a1""d2a2""e1l""e2l""d1a2""d2a1""d1c""e1c""d2c""e2c"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp