On Thu, Jan 29, 2026 at 12:27 PM Andres Freund <[email protected]> wrote:
> I was just trying to repro this again while writing this message, and
> interestingly I got the same issue in nbtree this time. Which a) confirms
> Peter's statement that the "conditionally locking a buffer we already locked"
> issue exists for nbtree b) makes me suspect something odd is happening around
> indexfsm.

I don't think that there's anything mysterious about it. This is just
how index vacuuming does free space management. It's a consequence of
the fact that VACUUM notices that a page can go in the FSM at one
point, but only actually updates the FSM at some other point.

Nothing stops a backend from finding a recyclable page in the FSM
after a concurrent VACUUM decides that that same page can go in the
FSM, but before actually placing that page in the FSM.  VACUUM doesn't
consider that the FSM might have already known about that page *at
all* -- and so it certainly doesn't try to avoid these kinds of race
conditions. Hence the need for _bt_allocbuf to worry about buffer lock
deadlocks, including even self-deadlock.

-- 
Peter Geoghegan


Reply via email to