Re: Parallel GIN, BRIN builds fail to maintain ii_BrokenHotChain

From: Lukas Fittl <lukas(at)fittl(dot)com>
To: Tomas Vondra <tomas(at)vondra(dot)me>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parallel GIN, BRIN builds fail to maintain ii_BrokenHotChain
Date: 2026-11-20 02:54:02
Message-ID: CAP53PkxOsGD-HOngqtGn8vDqTzuv6UBBksX7SAO409jz5dudtw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Nov 19, 2026 at 5:56 PM Tomas Vondra <tomas(at)vondra(dot)me> wrote:
>
> On 11/20/26 01:46, Peter Geoghegan wrote:
> > My LLM produced the attached patch, which adds an isolation test
> > showing that parallel index builds of both GIN and BRIN indexes fail
> > to maintain ii_BrokenHotChain correctly. The test fails, demonstrating
> > incorrect results.
> >
> > The underlying bug is straightforward: both GIN and BRIN lack the
> > required handling. If any individual parallel worker sets
> > ii_BrokenHotChain, then it has to be passed on to the leader so that
> > pg_index.indcheckxmin gets set correctly. Otherwise, older snapshots
> > can use the index even though it isn't guaranteed to have index tuples
> > for every row version that the snapshot can still see. nbtree gets
> > this right, but that precedent seems to have been missed.
> >
>
> Thanks for noticing it, and for the reproducer. I'll get it fixed
> (unless you want to take care of that).

I actually ran into the exact same issue and reported it over at [0]
together with a refactoring to prevent problems like this from
happening in the future. pgvector had the same issue and Andrew fixed
it recently based on that report [1].

For easier reference, attached the v2 patch from here that fixes that
specific issue as 0002, together with Peter's isolation test
reproducer from v1 kept as 0001. This now passes the test for me
locally.

[0]: https://www.postgresql.org/message-id/flat/CAP53PkxEZPeT_G7u-1qF-%3DouBvMxUNka-bN7cJowkv7gms9uCg%40mail.gmail.com#4fb55830a8fdca424c618a66837d1b0d
[1]: https://github.com/pgvector/pgvector/commit/9f973cd95f5ac3aab6ccb8ebdfb048188e4025e4

Thanks,
Lukas

--
Lukas Fittl

Attachment Content-Type Size
v2-0002-Fix-broken-HOT-chain-handling-in-parallel-BRIN-an.patch application/octet-stream 10.7 KB
v2-0001-Add-isolation-test-for-index-builds-over-broken-H.patch application/octet-stream 7.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-11-20 02:56:54 Re: Parallel vacuum: check XID wraparound failsafe between indexes
Previous Message Fujii Masao 2026-11-20 02:44:13 Re: A bug in recovery prefetcher, triggering asserts / FATAL: checkpoint request failed