Re: Buffer locking is special (hints, checksums, AIO writes)

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)
Date: 2026-01-29 18:12:35
Message-ID: CAH2-Wzm5FRt7dpKfpVH261wmHQ8c+rFn0ve22pd7cw0DDEVqNA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 29, 2026 at 12:27 PM Andres Freund <andres(at)anarazel(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-01-29 18:33:02 Re: Buffer locking is special (hints, checksums, AIO writes)
Previous Message Andres Freund 2026-01-29 18:06:22 Re: Buffer locking is special (hints, checksums, AIO writes)