Debian Codegraph @

contrib/test_decoding/specs/oldest_xmin.spec

raw
1 # Test advancement of the slot's oldest xmin
2
3 setup
4 {
5 SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding'); -- must be first write in xact
6 DROP TYPE IF EXISTS basket;
7 CREATE TYPE basket AS (apples integer, pears integer, mangos integer);
8 DROP TABLE IF EXISTS harvest;
9 CREATE TABLE harvest(fruits basket);
10 }
11
12 teardown
13 {
14 DROP TABLE IF EXISTS harvest;
15 DROP TYPE IF EXISTS basket;
16 SELECT 'stop' FROM pg_drop_replication_slot('isolation_slot');
17 }
18
19 session "s0"
20 setup { SET synchronous_commit=on; }
21 step "s0_begin" { BEGIN; }
22 step "s0_getxid" { SELECT pg_current_xact_id() IS NULL; }
23 step "s0_alter" { ALTER TYPE basket DROP ATTRIBUTE mangos; }
24 step "s0_commit" { COMMIT; }
25 step "s0_checkpoint" { CHECKPOINT; }
26 step "s0_vacuum" { VACUUM pg_attribute; }
27 step "s0_get_changes" { SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); }
28 step "s0_advance_slot" { SELECT slot_name FROM pg_replication_slot_advance('isolation_slot', pg_current_wal_lsn()); }
29
30 session "s1"
31 setup { SET synchronous_commit=on; }
32 step "s1_begin" { BEGIN; }
33 step "s1_insert" { INSERT INTO harvest VALUES ((1, 2, 3)); }
34 step "s1_commit" { COMMIT; }
35
36 # Checkpoint with following get_changes forces xmin advancement. We do
37 # get_changes twice because if one more xl_running_xacts record had slipped
38 # before our CHECKPOINT, xmin will be advanced only on this record, thus not
39 # reaching value needed for vacuuming corresponding pg_attribute entry. ALTER of
40 # composite type is a rare form of DDL which allows T1 to see the tuple which
41 # will be removed (xmax set) before T1 commits. That is, interlocking doesn't
42 # forbid modifying catalog after someone read it (and didn't commit yet).
43 permutation "s0_begin" "s0_getxid" "s1_begin" "s1_insert" "s0_alter" "s0_commit" "s0_checkpoint" "s0_get_changes" "s0_get_changes" "s1_commit" "s0_vacuum" "s0_get_changes"
44
45 # Perform the same testing process as described above, but use advance_slot to
46 # forces xmin advancement during fast forward decoding.
47 permutation "s0_begin" "s0_getxid" "s1_begin" "s1_insert" "s0_alter" "s0_commit" "s0_checkpoint" "s0_advance_slot" "s0_advance_slot" "s1_commit" "s0_vacuum" "s0_get_changes"