From: | Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> |
---|---|
To: | vignesh C <vignesh21(at)gmail(dot)com> |
Cc: | Peter Smith <smithpb2250(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(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-16 07:07:18 |
Message-ID: | CABdArM7YdCZKYoHakPE7LUe7cCdvS+447mGnVNxcq3jdSnjdvA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jan 13, 2025 at 12:22 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> On Thu, 2 Jan 2025 at 15:57, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
> >
> > Thank you for your feedback! Please find the v59 patch set addressing
> > all the comments.
> > Note: There are no new changes in patch-0001.
>
> Few comments:
> 1) I felt we should not invalidate the slots for which has no
> effective xmin set as they will not be holding the WAL files from
> deletion. This can happen when user created slots with
> immediately_reserve as false and lsn will be actually reserved only
> after the first connection from a streaming replication client:
> +static inline bool
> +CanInvalidateIdleSlot(ReplicationSlot *s)
> +{
> + return (idle_replication_slot_timeout_mins > 0 &&
> + s->inactive_since > 0 &&
> + !(RecoveryInProgress() && s->data.synced));
> +}
>
IIUC, for both logical and physical replication slots, the effective
xmin remains NULL until the respective nodes establish their first
connection. However, logical slots always reserve WAL immediately,
whereas physical slots do not unless immediately_reserve=true is set.
To avoid unnecessary slot invalidation for slots that are not
reserving WAL when created, it might be better to check the
restart_lsn instead of effective_xmin. If restart_lsn is invalid for a
slot, it indicates that WAL is not reserved for the slot, and we can
safely skip invalidation due to idle_timeout for such slots. This
logic has been implemented in v60.
--
Thanks,
Nisha
From | Date | Subject | |
---|---|---|---|
Next Message | Shinya Kato | 2025-01-16 07:09:44 | Re: [PATCH] New predefined role pg_manage_extensions |
Previous Message | Zhang Mingli | 2025-01-16 07:05:22 | Re: Inquiry About Determining Parallel Plans for REFRESH MATERIALIZED VIEW |