|
| 1 | +# Test that a slot creation skips to restore serialized snapshot to reach |
| 2 | +# the consistent state. |
| 3 | + |
| 4 | +setup |
| 5 | +{ |
| 6 | + DROP TABLE IF EXISTS tbl; |
| 7 | + CREATE TABLE tbl (val1 integer); |
| 8 | +} |
| 9 | + |
| 10 | +teardown |
| 11 | +{ |
| 12 | + DROP TABLE tbl; |
| 13 | + SELECT 'stop' FROM pg_drop_replication_slot('slot0'); |
| 14 | + SELECT 'stop' FROM pg_drop_replication_slot('slot1'); |
| 15 | +} |
| 16 | + |
| 17 | +session "s0" |
| 18 | +setup { SET synchronous_commit = on; } |
| 19 | +step "s0_init" { SELECT 'init' FROM pg_create_logical_replication_slot('slot0', 'test_decoding'); } |
| 20 | +step "s0_begin" { BEGIN; } |
| 21 | +step "s0_insert1" { INSERT INTO tbl VALUES (1); } |
| 22 | +step "s0_insert2" { INSERT INTO tbl VALUES (2); } |
| 23 | +step "s0_commit" { COMMIT; } |
| 24 | + |
| 25 | +session "s1" |
| 26 | +setup { SET synchronous_commit = on; } |
| 27 | +step "s1_init" { SELECT 'init' FROM pg_create_logical_replication_slot('slot1', 'test_decoding'); } |
| 28 | +step "s1_get_changes_slot0" { SELECT data FROM pg_logical_slot_get_changes('slot0', NULL, NULL, 'skip-empty-xacts', '1', 'include-xids', '0'); } |
| 29 | +step "s1_get_changes_slot1" { SELECT data FROM pg_logical_slot_get_changes('slot1', NULL, NULL, 'skip-empty-xacts', '1', 'include-xids', '0'); } |
| 30 | + |
| 31 | +session "s2" |
| 32 | +setup { SET synchronous_commit = on ;} |
| 33 | +step "s2_checkpoint" { CHECKPOINT; } |
| 34 | +step "s2_get_changes_slot0" { SELECT data FROM pg_logical_slot_get_changes('slot0', NULL, NULL, 'skip-empty-xacts', '1', 'include-xids', '0'); } |
| 35 | + |
| 36 | + |
| 37 | +# While 'slot1' creation by "s1_init" waits for s0-transaction to commit, the |
| 38 | +# RUNNING_XACTS record is written by "s2_checkpoint" and "s2_get_changes_slot1" |
| 39 | +# serializes consistent snapshots to the disk at LSNs where are before |
| 40 | +# s0-transaction's commit. After s0-transaction commits, "s1_init" resumes but |
| 41 | +# must not restore any serialized snapshots and will reach the consistent state |
| 42 | +# when decoding a RUNNING_XACT record generated after s0-transaction's commit. |
| 43 | +# We check if the get_changes on 'slot1' will not return any s0-transaction's |
| 44 | +# changes as its confirmed_flush_lsn will be after the s0-transaction's commit |
| 45 | +# record. |
| 46 | +permutation "s0_init" "s0_begin" "s0_insert1" "s1_init" "s2_checkpoint" "s2_get_changes_slot0" "s0_insert2" "s0_commit" "s1_get_changes_slot0" "s1_get_changes_slot1" |
0 commit comments