Re: index prefetching

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Yuhang Qiu <iamqyh(at)gmail(dot)com>
Cc: Rui Zhao <zhaorui126(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Andres Freund <andres(at)anarazel(dot)de>, Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Georgios <gkokolatos(at)protonmail(dot)com>, Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: index prefetching
Date: 2026-10-10 22:32:16
Message-ID: CAH2-WznVcopv-p42CqmJ3FzP3EXw41nWFCeEKi1jRo3csWRoZA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 23, 2026 at 2:44 AM Yuhang Qiu <iamqyh(at)gmail(dot)com> wrote:
> The GiST cleanup-lock fix appears to be incomplete on standbys.
> gistvacuumpage() already accounts for the root changing from a leaf page
> to an internal page while a scan holds a pin, but it only emits VACUUM
> WAL when it actually deletes index tuples from a leaf page.
>
> After a root split, a standby cursor may still hold a batch copied from
> the old root leaf, along with a pin on the root buffer. VACUUM acquires
> a cleanup lock on the now-internal root on the primary, but there is no
> corresponding WAL record to enforce that interlock on the standby. Heap
> cleanup and visibility map updates can therefore be replayed while the
> cursor still holds the old batch. When the cursor resumes and checks
> visibility for the remaining items, it can see the new all-visible bits,
> skip the heap checks, and return entries for deleted tuples. The
> necessary cleanup-lock barriers need to be WAL-logged even when there
> are no tuple deletions.

Essentially the same bug exists in nbtree on master, and on all
supported branches, and I don't think it's likely to get fixed anytime
soon:

https://postgr.es/m/CAH2-Wzkro678xEDOrsxrq-YDVP4w7nXybhVJV2MxrzTj-5OU4w@mail.gmail.com

Is there any reason to think that the issue is any worse with GiST and
SP-GiST using the amgetbatch design, compared to current nbtree?

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message best xmg 2026-10-10 22:36:49 Re: Hash a ScalarArrayOpExpr whose array is fixed for one execution
Previous Message Jim Jones 2026-10-10 22:27:04 Re: PoC: Simplify recovery after dropping a table by LOGGING the restore LSN