Debian Codegraph @

src/test/isolation/specs/skip-locked-2.spec

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