Re: Improve pg_sync_replication_slots() to wait for primary to advance

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Yilin Zhang <jiezhilove(at)126(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Improve pg_sync_replication_slots() to wait for primary to advance
Date: 2026-02-12 10:03:50
Message-ID: CAJpy0uCnLcHt5o09q6Rc2MhATQZrZfEO7u1pzs=tBZoyr-cgpw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 11, 2026 at 2:14 PM Zhijie Hou (Fujitsu)
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> On Tuesday, February 10, 2026 5:34 PM shveta malik <shveta(dot)malik(at)gmail(dot)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.
>

Thanks Hou-San. I have no more comments.

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Florin Irion 2026-02-12 10:11:55 Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement
Previous Message shveta malik 2026-02-12 10:02:56 Re: [PATCH] Support automatic sequence replication