RE: Improve pg_sync_replication_slots() to wait for primary to advance - Mailing list pgsql-hackers

From Zhijie Hou (Fujitsu)
Subject RE: Improve pg_sync_replication_slots() to wait for primary to advance
Date
Msg-id TY4PR01MB16907DD16098BE3B20486D4569463A@TY4PR01MB16907.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Improve pg_sync_replication_slots() to wait for primary to advance  (shveta malik <shveta.malik@gmail.com>)
Responses Re: Improve pg_sync_replication_slots() to wait for primary to advance
Re: Improve pg_sync_replication_slots() to wait for primary to advance
List pgsql-hackers
On Tuesday, February 10, 2026 5:34 PM shveta malik <shveta.malik@gmail.com> wrote:
> 
> Thanks for the patch.
> 
> + * Note that we do not wait and retry if the local slot has been invalidated.
> + * In such cases, the corresponding remote slot on the primary is
> + likely
> + * invalidated as well. Even if only the local slot is invalidated,
> + simply
> + * retrying synchronization won't suffice, as it requires further user
> + actions
> + * to verify the server configuration, drop the invalidated slot.
> 
> On thinking more, I realized that if the local slot is invalidated alone while the
> remote-slot is not, we do not wait for the user to drop such an invalidated
> slot. Instead slot-sync will drop it internally. See comments atop
> drop_local_obsolete_slots(). This makes me wonder whether such a case,
> where only the local slot is invalidated, should also set slotsync_pending =
> true, since there is a good chance it will get synchronized in subsequent runs.
> OTOH, if we do not wait for such a slot, we could end up in a situation where
> the slot (remote one) is valid pre-failover but is invalid (synced one) post-
> failover, even after running the API immediately before switchover. Thoughts?

I agree that it makes sense to retry when only the local slot is invalidated.

Here is the updated patch.

Best Regards,
Hou zj

Attachment

pgsql-hackers by date:

Previous
From: Anthonin Bonnefoy
Date:
Subject: Re: Propagate XLogFindNextRecord error to callers
Next
From: wangpeng
Date:
Subject: Fix wrong log in pgstat_report_checksum_failures_in_db()