Skip to content

Commit df2847e

Browse files
committed
add test
1 parent 5b7959f commit df2847e

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Parsed test spec with 3 sessions
2+
3+
starting permutation: s1lock s2lock s1svpt s3lock s1lock2 s2c s1c s3c
4+
step s1lock: SELECT * FROM justthis FOR SHARE;
5+
value
6+
7+
1
8+
step s2lock: SELECT * FROM justthis FOR SHARE;
9+
value
10+
11+
1
12+
step s1svpt: SAVEPOINT foo;
13+
step s3lock: SELECT * FROM justthis FOR UPDATE; <waiting ...>
14+
step s1lock2: SELECT * FROM justthis FOR SHARE;
15+
value
16+
17+
1
18+
step s2c: COMMIT;
19+
step s1c: COMMIT;
20+
step s3lock: <... completed>
21+
value
22+
23+
1
24+
step s3c: COMMIT;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# If we already hold a lock of a given strength, do not deadlock when
2+
# some other transaction is waiting for a conflicting lock and we try
3+
# to acquire the same lock we already held.
4+
setup
5+
{
6+
CREATE TABLE justthis (
7+
value int
8+
);
9+
10+
INSERT INTO justthis VALUES (1);
11+
}
12+
13+
teardown
14+
{
15+
DROP TABLE justthis;
16+
}
17+
18+
session "s1"
19+
setup { BEGIN; }
20+
step "s1lock" { SELECT * FROM justthis FOR SHARE; }
21+
step "s1svpt" { SAVEPOINT foo; }
22+
step "s1lock2" { SELECT * FROM justthis FOR SHARE; }
23+
step "s1c" { COMMIT; }
24+
25+
session "s2"
26+
setup { BEGIN; }
27+
step "s2lock" { SELECT * FROM justthis FOR SHARE; } # ensure it's a multi
28+
step "s2c" { COMMIT; }
29+
30+
session "s3"
31+
setup { BEGIN; }
32+
step "s3lock" { SELECT * FROM justthis FOR UPDATE; }
33+
step "s3c" { COMMIT; }
34+
35+
permutation "s1lock" "s2lock" "s1svpt" "s3lock" "s1lock2" "s2c" "s1c" "s3c"

0 commit comments

Comments
 (0)