+ # Let the released backend finish creating its slot: feed running-xacts + # records until it reaches a consistent point (poll_query_until re-runs the + # query, so pg_log_standby_snapshot() is called until the slot is created). + $primary->poll_query_until( + 'postgres', qq[ +select (pg_log_standby_snapshot() is not null) + and exists (select 1 from pg_replication_slots + where slot_name = 'slot_stray' and confirmed_flush_lsn is not null) +]);
I don't think we need to call pg_log_standby_snapshot() until the slot is created since the slot creation writes the running-xacts record during the slot creation.
--- + # Decoding the first slot must not stumble over a stray status-change record. + my ($decode_rc, $decode_out, $decode_err) = $primary->psql( + 'postgres', + qq[select count(*) from pg_logical_slot_get_changes('slot_first', null, null)], + on_error_die => 0); + is($decode_rc, 0, "decoding a concurrently-created slot succeeds"); + unlike( + $decode_err, + qr/unexpected logical decoding status change/, + "no redundant status-change record was decoded");
We can use safe_psql() to check if the query successfully completes.
makes sense.
I've made some cosmetic changes to the comment and the new test including the above comments. Please review it.