| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | Tomas Vondra <tomas(at)vondra(dot)me> |
| Cc: | Andres Freund <andres(at)anarazel(dot)de>, Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers(at)postgresql(dot)org, Tomas Vondra <tv(at)fuzzy(dot)cz>, Peter Geoghegan <pg(at)bowt(dot)ie> |
| Subject: | Re: gistGetFakeLSN() can return incorrect LSNs |
| Date: | 2026-03-13 11:33:50 |
| Message-ID: | CAHGQGwFrBJGyLk_aGUvT8902u3sQ1KKOeq7WREycqPnJ0n7zPw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Mar 13, 2026 at 8:12 PM Tomas Vondra <tomas(at)vondra(dot)me> wrote:
>
> On 3/5/26 21:25, Andres Freund wrote:
> > Hi,
> >
> > On 2026-03-05 10:52:03 -0800, Noah Misch wrote:
> >> On Thu, Mar 05, 2026 at 12:10:11PM -0500, Andres Freund wrote:
> >>> Tomas encountered a crash with the index prefetching patchset. One of the
> >>> patches included therein is a generalization of the gistGetFakeLSN()
> >>> mechanism, which is then used by other indexes as well. That triggered an
> >>> occasional, hard to locally reproduce, ERROR or PANIC in CI, about
> >>>
> >>> ERROR: xlog flush request 0/01BD2018 is not satisfied --- flushed only to 0/01BD2000
> >>
> >>> To be safe, this code would need to use a version of GetXLogInsertRecPtr()
> >>> that does use XLogBytePosToEndRecPtr() instead of XLogBytePosToRecPtr().
> >>
> >> I agree. Thanks for diagnosing it. Feel free to move forward with that
> >> strategy, or let me know if you'd like me to do it.
> >
> > I'd appreciate if you could do it.
> >
>
> Here's a fix for master (and backpatching). It introduces a new function
> GetXLogInsertEndRecPtr() and then uses that in gistGetFakeLSN(). I still
> need to test this a bit more, but it did fix the issue in our dev branch
> (where we saw regular failures). So I'm 99% sure it's fine.
>
> After writing the fix I had the idea to grep for GetXLogInsertRecPtr
> calls that might have similar issue (being passed to XLogFlush), and
> sure enough walsender does this:
>
> XLogFlush(GetXLogInsertRecPtr());
>
> Which AFAICS has the same issue, right? Funnily enough, this is a very
> new call, from 2026/03/06. Before 6eedb2a5fd88 walsender might flush not
> far enough, now it may be flushing too far ;-) AFAIK it should call the
> same GetXLogInsertEndRecPtr() once we have it.
Yes, this is already being discussed at [1], and Anthonin has also proposed
a patch there that adds GetXLogInsertEndRecPtr().
Regards,
[1] https://postgr.es/m/vzguaguldbcyfbyuq76qj7hx5qdr5kmh67gqkncyb2yhsygrdt@dfhcpteqifux
--
Fujii Masao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hayato Kuroda (Fujitsu) | 2026-03-13 11:35:41 | RE: [PATCH] Support automatic sequence replication |
| Previous Message | Alexander Korotkov | 2026-03-13 11:21:08 | Re: pg_atomic_compare_exchange_*() and memory barriers |