Debian Codegraph @

src/test/isolation/specs/nowait-2.spec

raw
1 # Test NOWAIT with multixact locks.
2
3 setup
4 {
5 CREATE TABLE foo (
6 id int PRIMARY KEY,
7 data text NOT NULL
8 );
9 INSERT INTO foo VALUES (1, 'x');
10 }
11
12 teardown
13 {
14 DROP TABLE foo;
15 }
16
17 session s1
18 setup { BEGIN; }
19 step s1a { SELECT * FROM foo FOR SHARE NOWAIT; }
20 step s1b { COMMIT; }
21
22 session s2
23 setup { BEGIN; }
24 step s2a { SELECT * FROM foo FOR SHARE NOWAIT; }
25 step s2b { SELECT * FROM foo FOR UPDATE NOWAIT; }
26 step s2c { COMMIT; }
27
28 # s1 and s2 both get SHARE lock, creating a multixact lock, then s2
29 # tries to upgrade to UPDATE but aborts because it cannot acquire a
30 # multi-xact lock
31 permutation s1a s2a s2b s1b s2c
32 # the same but with the SHARE locks acquired in a different order, so
33 # s2 again aborts because it can't acquired a multi-xact lock
34 permutation s2a s1a s2b s1b s2c
35 # s2 acquires SHARE then UPDATE, then s1 tries to acquire SHARE but
36 # can't so aborts because it can't acquire a regular lock
37 permutation s2a s2b s1a s1b s2c