Debian Codegraph @

contrib/test_decoding/specs/invalidation_distribution.spec

raw
1 # Test that catalog cache invalidation messages are distributed to ongoing
2 # transactions, ensuring they can access the updated catalog content after
3 # processing these messages.
4 setup
5 {
6 SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'pgoutput');
7 CREATE TABLE tbl1(val1 integer, val2 integer);
8 CREATE PUBLICATION pub;
9 }
10
11 teardown
12 {
13 DROP TABLE tbl1;
14 DROP PUBLICATION pub;
15 SELECT 'stop' FROM pg_drop_replication_slot('isolation_slot');
16 }
17
18 session "s1"
19 setup { SET synchronous_commit=on; }
20
21 step "s1_begin" { BEGIN; }
22 step "s1_insert_tbl1" { INSERT INTO tbl1 (val1, val2) VALUES (1, 1); }
23 step "s1_commit" { COMMIT; }
24
25 session "s2"
26 setup { SET synchronous_commit=on; }
27
28 step "s2_alter_pub_add_tbl" { ALTER PUBLICATION pub ADD TABLE tbl1; }
29 step "s2_get_binary_changes" { SELECT count(data) FROM pg_logical_slot_get_binary_changes('isolation_slot', NULL, NULL, 'proto_version', '4', 'publication_names', 'pub') WHERE get_byte(data, 0) = 73; }
30
31 session "s3"
32 setup { SET synchronous_commit=on; }
33 step "s3_begin" { BEGIN; }
34 step "s3_insert_tbl1" { INSERT INTO tbl1 (val1, val2) VALUES (2, 2); }
35 step "s3_commit" { COMMIT; }
36
37 # Expect to get one insert change. LOGICAL_REP_MSG_INSERT = 'I'
38 permutation "s1_insert_tbl1" "s1_begin" "s1_insert_tbl1" "s2_alter_pub_add_tbl" "s1_commit" "s1_insert_tbl1" "s2_get_binary_changes"
39
40 # Expect to get one insert change with LOGICAL_REP_MSG_INSERT = 'I' from
41 # the second "s1_insert_tbl1" executed after adding the table tbl1 to the
42 # publication in "s2_alter_pub_add_tbl".
43 permutation "s1_begin" "s1_insert_tbl1" "s3_begin" "s3_insert_tbl1" "s2_alter_pub_add_tbl" "s1_insert_tbl1" "s1_commit" "s3_commit" "s2_get_binary_changes"