Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Paul Kim <mok03127(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish
Date: 2026-10-09 04:57:30
Message-ID: CALj2ACVrzFVpD9gZNQwr-jo6GXGtBz48jEcprQuBGM1TmnOfiQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sat, Sep 12, 2026 at 4:52 AM Paul Kim <mok03127(at)gmail(dot)com> wrote:
>
> Whether XactLastRecEnd
> receiving a "start of the next record" position deserves a fix of its
> own is a fair follow-up question; the other consumers appear to cope
> with it, so I kept it out of this patch series.

Thanks for sending the v4 patches. TBH, fixing it in the WAL writer
looks like fixing the symptom of the issue. That approach also seems
to have a problem. XLogCtl->asyncXactLSN doesn't change until new WAL
is written, so the WAL writer keeps using the old value (B+40) and
keeps logging "request to flush past end of generated WAL" messages.

How about adjusting EndPos itself to the start of the segment (before
the page header) using XLogBytePosToEndRecPtr in this case, where the
switch WAL record falls right on the segment boundary, something like
the attached? This way, the switch record's EndPos (B+40) no longer
goes into XactLastRecEnd and XLogCtl->asyncXactLSN, and from there
into the WAL writer and WaitXLogInsertionsToFinish(). It fixes the
issue for me and the regression tests pass.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
nocfbot-0001-Fix-end-LSN-reported-for-an-xlog-switch-record-endin.patch application/x-patch 2.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-10-09 05:00:34 Re: WAL segment file descriptor leak on read errors can PANIC the server
Previous Message shihao zhong 2026-10-09 04:49:20 Re: [Patch] New pg_stat_tablespace view