Debian Codegraph @

src/test/isolation/specs/pub-concurrent-drop.spec

raw
1 # Tests for concurrently dropping a relation while a publication's tables are
2 # being listed.
3
4 setup
5 {
6 CREATE SCHEMA pubdrop;
7 CREATE PUBLICATION pub_schema FOR TABLES IN SCHEMA pubdrop;
8 CREATE TABLE pubdrop.dropme (id int);
9 CREATE TABLE pubdrop.keepme (id int);
10 }
11
12 teardown
13 {
14 DROP SCHEMA pubdrop CASCADE;
15 DROP PUBLICATION pub_schema;
16 }
17
18 session s1
19 step lock { BEGIN; LOCK pubdrop.dropme IN ACCESS EXCLUSIVE MODE; }
20 step drop_and_commit { DROP TABLE pubdrop.dropme; COMMIT; }
21
22 session s2
23 step list_pub_tables
24 {
25 SELECT relid::regclass AS tablename
26 FROM pg_get_publication_tables('pub_schema')
27 ORDER BY tablename;
28 }
29
30 # Hold an ACCESS EXCLUSIVE lock on the table in one session, so that the query
31 # listing a publication's tables in another session blocks when it tries to
32 # open the locked table. Then drop the table in the same lock-holding session
33 # and commit, releasing the lock, so the query in another session resumes and
34 # skips the now-dropped table instead of erroring with "could not open relation
35 # with OID".
36 permutation lock list_pub_tables drop_and_commit