From d53e54f5e53ce77f283d911fe31b80915732a600 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Thu, 8 Oct 2026 10:33:26 -0700 Subject: [PATCH] Stabilize recently added tests in 051_effective_wal_level.pl. Commit 1f2245371e3 added a test for the case where logical decoding is disabled and re-enabled while synchronizing a replication slot. Its cleanup assumed the slot re-created on retry would still be temporary, and so would be gone once the corresponding remote slot was dropped. That isn't guaranteed: the catalog_xmin reserved on the standby is not necessarily ahead of the remote slot's. In that case the slot is persisted on the first retry, and the subsequent logical decoding deactivation invalidates it on the standby rather than dropping it, so the check that no synced slot is left behind fails. Stabilize the cleanup by calling an extra pg_sync_replication_slots() after dropping the remote slot and before disabling logical decoding on the primary. Per buildfarm member skink. Reported-by: Fujii Masao Suggested-by: Fujii Masao Reviewed-by: shveta malik Discussion: https://postgr.es/m/CAHGQGwFWXASACRnhHJgEdk8nWyLw4bLLDhiEiKSqBqd+tzJ2Pg@mail.gmail.com Backpatch-through: 19 --- src/test/recovery/t/051_effective_wal_level.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/recovery/t/051_effective_wal_level.pl b/src/test/recovery/t/051_effective_wal_level.pl index ec8c3dc0684..c9c98c6514d 100644 --- a/src/test/recovery/t/051_effective_wal_level.pl +++ b/src/test/recovery/t/051_effective_wal_level.pl @@ -686,10 +686,9 @@ select injection_points_wakeup('replication-slot-create-begin'); or die "timed out waiting for the slot to be re-created from the re-created remote slot"; - # The slot created on retry might not be persisted until the remote slot - # catches up with the catalog_xmin computed locally. Drop the remote slot - # to let the slot synchronization finish, keeping logical decoding enabled - # with another slot as the slot synchronization requires it. + # Drop the remote slot so that the slot synchronization has nothing left + # to retry, keeping logical decoding enabled with another slot as the + # slot synchronization requires it. $primary->safe_psql( 'postgres', qq[ select pg_create_logical_replication_slot('test_slot4', 'test_decoding'); @@ -697,6 +696,12 @@ select pg_drop_replication_slot('sync_slot'); ]); $primary->wait_for_replay_catchup($standby5); $psql_sync_slot->quit; + + # The slot created on retry may or may not have been persisted by the + # time the remote slot was dropped. One more synchronization cycle + # drops the local slot either way. + $standby5->safe_psql('postgres', qq[select pg_sync_replication_slots()]); + $primary->safe_psql('postgres', qq[select pg_drop_replication_slot('test_slot4')]); wait_for_logical_decoding_disabled($primary);