Stabilize 019_replslot_limit.pl: wait on slot restart_lsn

wait_for_catchup() has "wait for the standby to reach the target LSN"
semantics.  However, the previous polling implementation actually waited for
the primary to observe that position via pg_stat_replication.
7e8aeb9e48 introduced the new WAIT FOR LSN-based implementation, which
just probes the standby.

019_replslot_limit.pl relied on the old side effect: its
"slot state changes to extended/unreserved" subtests inspect
primary-side pg_replication_slots, whose wal_status depends on
restart_lsn, which only advances after the walsender processes a
standby reply.  Make the test wait on what it actually needs by
replacing each wait_for_catchup() with
wait_for_slot_catchup('rep1', 'restart', primary->lsn('write')).

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/63f6abc9-c0ae-465d-a4e6-667eca6ea008@gmail.com
Author: Xuneng Zhou <xunengzhou@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com>
This commit is contained in:
Alexander Korotkov 2026-05-27 02:54:04 +03:00
parent bec61f5935
commit cdb1d1cf1d

View file

@ -44,8 +44,12 @@ $node_standby->append_conf('postgresql.conf', "primary_slot_name = 'rep1'");
$node_standby->start;
# Wait until standby has replayed enough data
$node_primary->wait_for_catchup($node_standby);
# Wait until the primary has processed standby feedback and advanced the
# slot's restart_lsn. For a physical slot, restart_lsn is updated from
# the standby's reported flush position, so this waits for the primary-side
# slot state that the following wal_status checks depend on.
$node_primary->wait_for_slot_catchup('rep1', 'restart',
$node_primary->lsn('write'));
# Stop standby
$node_standby->stop;
@ -79,7 +83,8 @@ is($result, "reserved|t", 'check that slot is working');
# The standby can reconnect to primary
$node_standby->start;
$node_primary->wait_for_catchup($node_standby);
$node_primary->wait_for_slot_catchup('rep1', 'restart',
$node_primary->lsn('write'));
$node_standby->stop;
@ -109,7 +114,8 @@ is($result, "reserved",
# The standby can reconnect to primary
$node_standby->start;
$node_primary->wait_for_catchup($node_standby);
$node_primary->wait_for_slot_catchup('rep1', 'restart',
$node_primary->lsn('write'));
$node_standby->stop;
# wal_keep_size overrides max_slot_wal_keep_size
@ -128,7 +134,8 @@ $result = $node_primary->safe_psql('postgres',
# The standby can reconnect to primary
$node_standby->start;
$node_primary->wait_for_catchup($node_standby);
$node_primary->wait_for_slot_catchup('rep1', 'restart',
$node_primary->lsn('write'));
$node_standby->stop;
# Advance WAL again without checkpoint, reducing remain by 6 MB.
@ -155,7 +162,8 @@ is($result, "unreserved|t",
# The standby still can connect to primary before a checkpoint
$node_standby->start;
$node_primary->wait_for_catchup($node_standby);
$node_primary->wait_for_slot_catchup('rep1', 'restart',
$node_primary->lsn('write'));
$node_standby->stop;