Re: GetBufferDescriptor() being called for local buffers from MarkBufferDirtyHint()

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-10T22:14:33Z
Lists: pgsql-hackers
On Wed, Jun 10, 2026 at 10:36:22AM -0400, Andres Freund wrote:
> I think it *should* blow up. It doesn't because we're lacking assertions in
> GetBufferDescriptor(). But I don't think the assertions added in the patch are
> quite right.
> 
> We can't trivially add the correct assertions, because somebody though it was
> a good idea to give GetBufferDescriptor() a uint32 parameter, which seems
> completely wrong to me.

This one is not as old as I expected: 3ac88fddd92c.  You're right that
switching that to be signed would be a correct first step forward.
--
Michael

Commits

  1. Switch Get[Local]BufferDescriptor() to use a signed value in input

  2. Fix MarkBufferDirtyHint() to not call GetBufferDescriptor() for local buffers

  3. Require share-exclusive lock to set hint bits and to flush