Re: Introduce XID age based replication slot invalidation

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: 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-04-03 19:04:48
Message-ID: CALj2ACXR=5SoApm6duEOc6pi=-KaBqSxuSP6XNQot2LywrqtAA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Apr 1, 2026 at 2:21 PM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>
> On Wed, Apr 1, 2026 at 12:39 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> >
> > I've reviewed the v7 patch and have some review comments:
>
> Thank you for reviewing the patch.
>
> I took the above changes into v8 and fixed a typo in using xidLimit
> instead of slotXidLimit.
>
> Please find the attached v8 patches for further review. Thank you!

Thank you, Sawada-san, for reviewing and providing some offlist comments.

1/ Included a note in the docs to say that logical replication slots
are also affected by XID age GUC (similar to
idle_replication_slot_timeout).

2/ Added the code to disable the XID age invalidation in
pg_createsubscriber similar to timeout invalidation. Commit 72e6c08fea
ensured that none of the logical replication slots get invalidated
during the upgrade. (I believe the work that pg_upgrade and
pg_createsubscriber do is more important, and the slots created and
used by them or slots in use during those processes must not interfere
with the upgrade or creating a logical replica from a standby.)

3/ Changed the max value of XID age GUC to be equal to that of vacuum
failsafe age. In my opinion, the best use of max_slot_xid_age would be
to set it equal to or a little less than vacuum_failsafe_age. Also
added a note in the docs about this.

4/ Changed variable names for consistency.

5/ Added code to MaybeInvalidateXIDAgedSlots() to skip the slot
invalidation attempt (unnecessary work) when slots are not the reason
for holding back the OldestXmin. Added an equality check to see if
OldestXmin is either OldestSlotXmin or OldestSlotCatalogXmin (all
these OldestXXXXmins are computed from the same ComputeXidHorizons()
call). This should allow us to skip the slot invalidation attempt when
a backend is holding the xmin back (a long-running transaction, for
example).

Please find the attached v9 patches for further review. Thank you!

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

Attachment Content-Type Size
v9-0001-Add-XID-age-based-replication-slot-invalidation.patch application/octet-stream 33.6 KB
v9-0002-Add-more-tests-for-XID-age-slot-invalidation.patch application/octet-stream 6.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2026-04-03 19:04:51 Re: AIO / read stream heuristics adjustments for index prefetching
Previous Message Andres Freund 2026-04-03 19:01:13 Re: AIO / read stream heuristics adjustments for index prefetching