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

From: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, vignesh C <vignesh21(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-01-22 05:16:45
Message-ID: CABdArM5ayb1Dgb0cWnjojh+8fSKqFRPhnGxYBxG4S8ZbPnBP9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 21, 2025 at 8:26 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Some review comments for patch v61-0002
>
> ======
> src/backend/replication/slot.c
>
> 1.
> * Whether a slot needs to be invalidated depends on the cause. A slot is
> - * removed if it:
> + * invalidated if it:
> * - RS_INVAL_WAL_REMOVED: requires a LSN older than the given segment
> * - RS_INVAL_HORIZON: requires a snapshot <= the given horizon in the given
> * db; dboid may be InvalidOid for shared relations
> * - RS_INVAL_WAL_LEVEL: is logical
> + * - RS_INVAL_IDLE_TIMEOUT: idle slot timeout has occurred
>
> 1a.
> Firstly the wording seems odd. "Is invalidated if it:" (missing words?)
>
> ~
>
> 1b.
> Secondly, is this comment strictly correct? IIUC it's not *always*
> going to be invalidated just because the cause is one of those listed.
> e.g. the code calls InvalidatePossiblyObsoleteSlot but it might not
> end up invalidating the slot having a cause RS_INVAL_IDLE_TIMEOUT.
>

I feel the phrase "A slot is invalidated if it:" is supposed to be
read alongside the respective cause description, such as:
"A slot is invalidated if it requires an LSN older than…"
"A slot is invalidated if it requires a snapshot <= the…"
"A slot is invalidated if it is logical"

IIUC, each listed cause specifies a clear condition under which the
slot should *always* be invalidated for that cause. To maintain
consistency with the header line "A slot is invalidated if it:", I’ve
modified the description/condition for RS_INVAL_IDLE_TIMEOUT
accordingly. Also, corrected the RS_INVAL_WAL_LEVEL description.

Attached the v62 patch set with above mentioned changes and also
addressed comments at [1].

[1] https://www.postgresql.org/message-id/CAHut%2BPvC4uPabeGMvDuTQ4S%2B5eX66Y6%2BtU5QMRmB2jDw-Cj2Cw%40mail.gmail.com

--
Thanks,
Nisha

Attachment Content-Type Size
v62-0001-Enhance-replication-slot-error-handling-slot-inv.patch application/octet-stream 15.7 KB
v62-0002-Introduce-inactive_timeout-based-replication-slo.patch application/octet-stream 32.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nisha Moond 2025-01-22 05:19:28 Re: Introduce XID age and inactive timeout based replication slot invalidation
Previous Message Hayato Kuroda (Fujitsu) 2025-01-22 04:38:09 RE: pgbench without dbname worked differently with psql and pg_dump