8000 Make new deadlock isolation test more reproducible. · lisael/postgres@b11d07b · GitHub
[go: up one dir, main page]

Skip to content

Commit b11d07b

Browse files
committed
Make new deadlock isolation test more reproducible.
The original formulation of 4c9864b was extremely timing-sensitive, because it arranged for the deadlock detector to be running (and possibly unblocking the current query) at almost exactly the same time as isolationtester would be probing to see if the query is blocked. The committed expected-file assumed that the deadlock detection would finish first, but we see the opposite on both fast and slow buildfarm animals. Adjust the deadlock timeout settings to make it predictable that isolationtester *will* see the query as waiting before deadlock detection unblocks it. I used a 5s timeout for the same reasons mentioned in a7921f7.
1 parent d9dc2b4 commit b11d07b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/test/isolation/expected/deadlock-hard.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ step s4a5: LOCK TABLE a5; <waiting ...>
1616
step s5a6: LOCK TABLE a6; <waiting ...>
1717
step s6a7: LOCK TABLE a7; <waiting ...>
1818
step s7a8: LOCK TABLE a8; <waiting ...>
19-
step s8a1: LOCK TABLE a1;
19+
step s8a1: LOCK TABLE a1; <waiting ...>
20+
step s8a1: <... completed>
2021
step s7a8: <... completed>
2122
error in steps s8a1 s7a8: ERROR: deadlock detected
2223
step s8c: COMMIT;

src/test/isolation/specs/deadlock-hard.spec

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 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.
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.
45

56
setup
< 10000 /td>
67
{
@@ -20,49 +21,49 @@ teardown
2021
}
2122

2223
session "s1"
23-
setup { BEGIN; SET deadlock_timeout = '10s'; }
24+
setup { BEGIN; SET deadlock_timeout = '100s'; }
2425
step "s1a1" { LOCK TABLE a1; }
2526
step "s1a2" { LOCK TABLE a2; }
2627
step "s1c" { COMMIT; }
2728

2829
session "s2"
29-
setup { BEGIN; SET deadlock_timeout = '10s'; }
30+
setup { BEGIN; SET deadlock_timeout = '100s'; }
3031
step "s2a2" { LOCK TABLE a2; }
3132
step "s2a3" { LOCK TABLE a3; }
3233
step "s2c" { COMMIT; }
3334

3435
session "s3"
35-
setup { BEGIN; SET deadlock_timeout = '10s'; }
36+
setup { BEGIN; SET deadlock_timeout = '100s'; }
3637
step "s3a3" { LOCK TABLE a3; }
3738
step "s3a4" { LOCK TABLE a4; }
3839
step "s3c" { COMMIT; }
3940

4041
session "s4"
41-
setup { BEGIN; SET deadlock_timeout = '10s'; }
42+
setup { BEGIN; SET deadlock_timeout = '100s'; }
4243
step "s4a4" { LOCK TABLE a4; }
4344
step "s4a5" { LOCK TABLE a5; }
4445
step "s4c" { COMMIT; }
4546

4647
session "s5"
47-
setup { BEGIN; SET deadlock_timeout = '10s'; }
48+
setup { BEGIN; SET deadlock_timeout = '100s'; }
4849
step "s5a5" { LOCK TABLE a5; }
4950
step "s5a6" { LOCK TABLE a6; }
5051
step "s5c" { COMMIT; }
5152

5253
session "s6"
53-
setup { BEGIN; SET deadlock_timeout = '10s'; }
54+
setup { BEGIN; SET deadlock_timeout = '100s'; }
5455
step "s6a6" { LOCK TABLE a6; }
5556
step "s6a7" { LOCK TABLE a7; }
5657
step "s6c" { COMMIT; }
5758

5859
session "s7"
59-
setup { BEGIN; SET deadlock_timeout = '10s'; }
60+
setup { BEGIN; SET deadlock_timeout = '100s'; }
6061
step "s7a7" { LOCK TABLE a7; }
6162
step "s7a8" { LOCK TABLE a8; }
6263
step "s7c" { COMMIT; }
6364

6465
session "s8"
65-
setup { BEGIN; SET deadlock_timeout = '10ms'; }
66+
setup { BEGIN; SET deadlock_timeout = '5s'; }
6667
step "s8a8" { LOCK TABLE a8; }
6768
step "s8a1" { LOCK TABLE a1; }
6869
step "s8c" { COMMIT; }

0 commit comments

Comments
 (0)
0