Re: Buffer locking is special (hints, checksums, AIO writes) - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Buffer locking is special (hints, checksums, AIO writes)
Date
Msg-id CAH2-Wzm5FRt7dpKfpVH261wmHQ8c+rFn0ve22pd7cw0DDEVqNA@mail.gmail.com
Whole thread Raw
In response to Re: Buffer locking is special (hints, checksums, AIO writes)  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Thu, Jan 29, 2026 at 12:27 PM Andres Freund <andres@anarazel.de> 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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)
Next
From: Peter Geoghegan
Date:
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)