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

From: Andres Freund <andres(at)anarazel(dot)de>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, 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-14 00:49:00
Message-ID: yf5bsdiirw6yurixiqddv7tk3q4v6n2qgpygo46asgpgqfht2n@hvudsugxixu7
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-01-13 10:05:02 -0500, Melanie Plageman wrote:
> On Mon, Jan 12, 2026 at 7:33 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> >
> > - added a commit that renames ResOwnerReleaseBufferPin to
> > ResOwnerReleaseBuffer (et al), as it now also releases content locks if held
> >
> > I kept this separate as I'm not yet sure about the new name, partially due
> > to there also being a "buffer io" resowner. I tried "buffer ownership" for
> > the resowner that tracks pins and locks, but that was long and not clearly
> > better.
>
> I didn't look at the patch but I strongly agree that
> ResOwnerReleaseBufferPin() should not also release locks, so it should
> have a new name.

OK.

> Ironic that ResOwnerReleaseBufferIO() releases pins and not locks.

Not sure I follow? I don't think it releases pins? And why should it release
locks?

> What about ResOwnerReleaseBufferClaim() or
> ResOwnerReleaseBufferAccess() or ResOwnerReleaseBufferHold()?

I'm inclined to go with just ResOwnerReleaseBuffer() at the moment. Buffer IO
kind of is a subsidiary thing, and it requires holding a pin as well, so it
doesn't feel too wrong.

I also wonder if we could merge BufferIO into the private refcount
infrastructure, similar to how the patches store the lockmode in the private
refcount. The separate resowner acquisition does show up in profiles when
reading from the kernel page cache, so that'd be a nice (but small)
improvement.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-01-14 00:52:18 Re: ALTER TABLE: warn when actions do not recurse to partitions
Previous Message Jacob Champion 2026-01-14 00:41:55 Re: [oauth] SASL mechanisms