Debian Codegraph @

src/test/isolation/specs/partition-key-update-2.spec

raw
1 # Concurrent update of a partition key and INSERT...ON CONFLICT DO NOTHING test
2 #
3 # This test tries to expose problems with the interaction between concurrent
4 # sessions during an update of the partition key and INSERT...ON CONFLICT DO
5 # NOTHING on a partitioned table.
6 #
7 # The convention here is that session 1 moves row from one partition to
8 # another due update of the partition key and session 2 always ends up
9 # inserting, and session 3 always ends up doing nothing.
10 #
11 # Note: This test is slightly resemble to insert-conflict-do-nothing test.
12
13 setup
14 {
15 CREATE TABLE foo (a int primary key, b text) PARTITION BY LIST(a);
16 CREATE TABLE foo1 PARTITION OF foo FOR VALUES IN (1);
17 CREATE TABLE foo2 PARTITION OF foo FOR VALUES IN (2);
18 INSERT INTO foo VALUES (1, 'initial tuple');
19 }
20
21 teardown
22 {
23 DROP TABLE foo;
24 }
25
26 session s1
27 setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
28 step s1u { UPDATE foo SET a=2, b=b || ' -> moved by session-1' WHERE a=1; }
29 step s1c { COMMIT; }
30
31 session s2
32 setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
33 step s2donothing { INSERT INTO foo VALUES(1, 'session-2 donothing') ON CONFLICT DO NOTHING; }
34 step s2c { COMMIT; }
35
36 session s3
37 setup { BEGIN ISOLATION LEVEL READ COMMITTED; }
38 step s3donothing { INSERT INTO foo VALUES(2, 'session-3 donothing') ON CONFLICT DO NOTHING; }
39 step s3select { SELECT * FROM foo ORDER BY a; }
40 step s3c { COMMIT; }
41
42 # Regular case where one session block-waits on another to determine if it
43 # should proceed with an insert or do nothing.
44 permutation s1u s2donothing s3donothing s1c s2c s3select s3c
45 permutation s2donothing s1u s3donothing s1c s2c s3select s3c