04.11.2021, 04:33, "Peter Geoghegan" <pg@bowt.ie>:

But what about index-only scans, which GiST also supports? I think
that the rules are different there, even though index-only scans use
an MVCC snapshot.

Let's enumerate steps how things can go wrong.

Backend1: Index-Only scan returns tid and xs_hitup with index_tuple1 on index_page1 pointing to heap_tuple1 on page1

Backend2: Remove index_tuple1 and heap_tuple1

Backend3: Mark page1 all-visible
Backend1: Thinks that page1 is all-visible and shows index_tuple1 as visible
 
To avoid this Backend1 must hold pin on index_page1 until it's done with checking visibility, and Backend2 must do LockBufferForCleanup(index_page1). Do I get things right?
 
Best regards, Andrey Borodin.