Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Vitaly Davydov <v(dot)davydov(at)postgrespro(dot)ru>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "tomas(at)vondra(dot)me" <tomas(at)vondra(dot)me>
Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
Date: 2025-06-18 16:47:09
Message-ID: CAPpHfdv3UEUBjsLhB_CwJT0xX9LmN6U+__myYopq4KcgvCSbTg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 18, 2025 at 6:50 PM Vitaly Davydov <v(dot)davydov(at)postgrespro(dot)ru> wrote:
> > I think, it is a good idea. Once we do not use the generated data, it is ok
> > just to generate WAL segments using the proposed function. I've tested this
> > function. The tests worked as expected with and without the fix. The attached
> > patch does the change.
>
> Sorry, forgot to attach the patch. It is created on the current master branch.
> It may conflict with your corrections. I hope, it could be useful.

Thank you. I've integrated this into a patch to improve these tests.

Regarding assertion failure, I've found that assert in
PhysicalConfirmReceivedLocation() conflicts with restart_lsn
previously set by ReplicationSlotReserveWal(). As I can see,
ReplicationSlotReserveWal() just picks fresh XLogCtl->RedoRecPtr lsn.
So, it doesn't seems there is a guarantee that restart_lsn never goes
backward. The commit in ReplicationSlotReserveWal() even states there
is a "chance that we have to retry". Thus, I propose to remove the
assertion introduced by ca307d5cec90.

Any objection from backpatching 0001 though 17 and pushing 0002 to the head?

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v4-0002-Remove-excess-assert-from-InvalidatePossiblyObsol.patch application/octet-stream 1.3 KB
v4-0001-Improve-runtime-and-output-of-tests-for-replicati.patch application/octet-stream 6.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2025-06-18 16:53:01 Re: pg_dump --with-* options
Previous Message Andres Freund 2025-06-18 16:38:41 Re: minimum Meson version