Re: Introduce XID age based replication slot invalidation

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, John H <johnhyvr(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Introduce XID age based replication slot invalidation
Date: 2026-08-21 22:05:00
Message-ID: CALj2ACUi0LeqKzomuXNPFsekzuQ+XbWZ5RamnO6tDzG4i1-KLw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sat, Aug 15, 2026 at 10:35 PM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>
> On Thu, Aug 13, 2026 at 9:40 PM Bertrand Drouvot
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>
> > Yeah, I agree. Keeping the exemption for idle_replication_slot_timeout but
> > removing it from CanInvalidateXidAgedSlot() makes sense to me.
>
> > Worth adding a test with an actual synced slot, including checking that its
> > invalidation releases the feedback horizon on the primary?
>
> Yes, I will do so. I will turn either one of the following (maybe test
> 2 for determinism) into a test by ensuring that the synced slot on the
> standby gets XID-age invalidated while its corresponding failover slot
> and physical slot on the primary don't get invalidated, and ensure
> that vacuum on the system catalogs doesn't get blocked.
>
> 1/ Slot sync worker stuck or erroring: the synced slot's catalog_xmin
> is old and gets sent onto the physical slot on the primary via HS
> feedback.
> 2/ Slot sync worker is off with rare/missing/forgotten manual syncs:
> the synced slot's catalog_xmin is old and gets sent onto the physical
> slot on the primary via HS feedback.

Added case 2 as a TAP test in the attached 0003 patch.

On Tue, Aug 18, 2026 at 12:42 PM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>
> On Mon, Aug 17, 2026 at 10:46 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > > I believe this can happen in practice (as explained above). IMHO, XID
> > > age based slot invalidation must invalidate the synced slot on the
> > > standby (just like other invalidations except the idle-timeout based)
> > > if its catalog_xmin is aged and blocking vacuum on the primary.
> >
> > Fair enough, then let's invalidate synced slots as well on standby due
> > to xid_age
>
> Thanks. I will post the new patches soon.

Please find the attached v14 patches. 0003 now adds support for
invalidating XID-aged synced replication slots on standbys.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v14-0001-Invalidate-XID-aged-replication-slots.patch application/x-patch 29.1 KB
v14-0002-Allow-vacuum-to-invalidate-XID-aged-replication-.patch application/x-patch 29.1 KB
v14-0003-Invalidate-XID-aged-synced-replication-slots-on-.patch application/x-patch 8.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Haibo Yan 2026-08-21 22:17:56 Re: missing possibility to use alternative translated month names in to_char function
Previous Message Nathan Bossart 2026-08-21 21:51:30 Re: split tablecmds.c