Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c957813

Browse files
committed
Add isolationtester spec for old heapam.c bug
In 0e5680f, I fixed a bug in heapam that caused spurious deadlocks when multiple updates concurrently attempted to modify the old version of an updated tuple whose new version was key-share locked. I proposed an isolationtester spec file that reproduced the bug, but back then isolationtester wasn't mature enough to be able to run it. Now that 38f8bdc is in the tree, we can have this spec file too. Discussion: https://www.postgresql.org/message-id/20141212205254.GC1768%40alvh.no-ip.org
1 parent 74d5842 commit c957813

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Parsed test spec with 4 sessions
2+
3+
starting permutation: s1_advlock s2_update s3_update s4_update s1_chain s1_begin s1_grablock s1_advunlock s1_commit
4+
step s1_advlock: SELECT pg_advisory_lock(142857);
5+
pg_advisory_lock
6+
7+
8+
step s2_update: UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; <waiting ...>
9+
step s3_update: UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; <waiting ...>
10+
step s4_update: UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; <waiting ...>
11+
step s1_chain: UPDATE pktab SET data = DEFAULT;
12+
step s1_begin: BEGIN;
13+
step s1_grablock: SELECT * FROM pktab FOR KEY SHARE;
14+
id data
15+
16+
1 2
17+
step s1_advunlock: SELECT pg_advisory_unlock(142857);
18+
pg_advisory_unlock
19+
20+
t
21+
step s2_update: <... completed>
22+
step s3_update: <... completed>
23+
step s4_update: <... completed>
24+
step s1_commit: COMMIT;

src/test/isolation/isolation_schedule

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ test: multixact-no-deadlock
3131
test: multixact-no-forget
3232
test: propagate-lock-delete
3333
test: tuplelock-conflict
34+
test: tuplelock-update
3435
test: nowait
3536
test: nowait-2
3637
test: nowait-3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
setup {
2+
DROP TABLE IF EXISTS pktab;
3+
CREATE TABLE pktab (id int PRIMARY KEY, data SERIAL NOT NULL);
4+
INSERT INTO pktab VALUES (1, DEFAULT);
5+
}
6+
7+
teardown {
8+
DROP TABLE pktab;
9+
}
10+
11+
session "s1"
12+
step "s1_advlock" { SELECT pg_advisory_lock(142857); }
13+
step "s1_chain" { UPDATE pktab SET data = DEFAULT; }
14+
step "s1_begin" { BEGIN; }
15+
step "s1_grablock" { SELECT * FROM pktab FOR KEY SHARE; }
16+
step "s1_advunlock" { SELECT pg_advisory_unlock(142857); }
17+
step "s1_commit" { COMMIT; }
18+
19+
session "s2"
20+
step "s2_update" { UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; }
21+
22+
session "s3"
23+
step "s3_update" { UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; }
24+
25+
session "s4"
26+
step "s4_update" { UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; }
27+
28+
permutation "s1_advlock" "s2_update" "s3_update" "s4_update" "s1_chain" "s1_begin" "s1_grablock" "s1_advunlock" "s1_commit"

0 commit comments

Comments
 (0)