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

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Peter Smith <smithpb2250(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-07 05:52:54
Message-ID: CAA4eK1Jatoapf2NoX2nJOJ8k-RvEZM=MoFUvNWPz4rRR1simQw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniil Davydov 2025-02-07 05:54:00 Re: SLRU_PAGES_PER_SEGMENT as configure parameter
Previous Message Jacob Champion 2025-02-07 05:48:19 Re: [PoC] Federated Authn/z with OAUTHBEARER