Re: Newly created replication slot may be invalidated by checkpoint

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Vitaly Davydov <v(dot)davydov(at)postgrespro(dot)ru>
Cc: "suyu(dot)cmj" <mengjuan(dot)cmj(at)alibaba-inc(dot)com>, aekorotkov <aekorotkov(at)gmail(dot)com>, tomas <tomas(at)vondra(dot)me>, michael <michael(at)paquier(dot)xyz>, "bharath(dot)rupireddyforpostgres" <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Newly created replication slot may be invalidated by checkpoint
Date: 2025-09-24 11:20:55
Message-ID: CAA4eK1JD3nvg-w3X2XguR3DZc_NjrHT+pFeyJ1XYh+dDhk7LoQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 23, 2025 at 12:19 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Wed, Sep 17, 2025 at 4:19 PM Vitaly Davydov <v(dot)davydov(at)postgrespro(dot)ru> wrote:
> >
> > [1] 0001-Fix-invalidation-when-slot-is-created-during-checkpo.patch
> >
>
> - /* Calculate how many segments are kept by slots. */
> - keep = slotsMinReqLSN;
> + /*
> + * Calculate how many segments are kept by slots. Keep the wal using
> + * the minimal value from the current reserved LSN and the reserved LSN at
> + * the moment of checkpoint start (before CheckPointReplicationSlots).
> + */
> + keep = XLogGetReplicationSlotMinimumLSN();
> + if (!XLogRecPtrIsInvalid(slotsMinReqLSN))
> + keep = Min(keep, slotsMinReqLSN);
>
> Can we add why we need this additional calculation here?
>

I was thinking some more about this solution. Won't it lead to the
same problem if ReplicationSlotReserveWal() calls
ReplicationSlotsComputeRequiredLSN() after the above calculation of
checkpointer?

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-09-24 11:22:28 Re: "openssl" should not be optional
Previous Message Christoph Berg 2025-09-24 11:14:47 "openssl" should not be optional