Re: Introduce XID age and inactive timeout based replication slot invalidation

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation
Date: 2025-02-10 06:10:14
Message-ID: CAHut+PuYmEiiCZP3yj1AnRp1qhZpzQyDrvhWdVWsWiykzU_-Nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 7, 2025 at 4:53 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Fri, Feb 7, 2025 at 8:00 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> >
> > ======
> > src/backend/access/transam/xlog.c
> >
> > 1.
> > XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size);
> > KeepLogSeg(recptr, &_logSegNo);
> > - if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED,
> > + if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED |
> > RS_INVAL_IDLE_TIMEOUT,
> > _logSegNo, InvalidOid,
> > InvalidTransactionId))
> > {
> > @@ -7792,7 +7792,7 @@ CreateRestartPoint(int flags)
> > replayPtr = GetXLogReplayRecPtr(&replayTLI);
> > endptr = (receivePtr < replayPtr) ? replayPtr : receivePtr;
> > KeepLogSeg(endptr, &_logSegNo);
> > - if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED,
> > + if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED |
> > RS_INVAL_IDLE_TIMEOUT,
> > _logSegNo, InvalidOid,
> > InvalidTransactionId))
> >
> > It seems fundamentally strange to me to assign multiple simultaneous
> > causes like this. IMO you can't invalidate something that is invalid
> > already. I gues v71 was an attempt to implement Amit's:
> >
>
> The idea is to invalidate the slot either due to WAL_REMOVED or
> IDLE_TIMEOUT in one go during the checkpoint instead of taking
> multiple passes over the slots during the checkpoint. Feel free to
> suggest if you can think of a better way to implement it.
>

Hi Amit,

My preference already suggested was to have a separation between the
concepts of *actual* causes (e.g. discrete enum values like in v70)
and *possible* causes to be checked (using #defines for bit flags).

My v72-0001 review [1] includes a top-up patch to show what doing it
this way might look like.

======
[1] https://www.postgresql.org/message-id/CAHut%2BPupn_S0mrM2zB%2BFwAbPqVak7jwSjRhU3WyA18QC1HU__g%40mail.gmail.com

Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2025-02-10 06:14:00 Re: SQL Property Graph Queries (SQL/PGQ)
Previous Message Amit Kapila 2025-02-10 06:09:45 Re: Introduce XID age and inactive timeout based replication slot invalidation