Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer
Date: 2025-08-09 04:03:41
Message-ID: CA+hUKG+cK955=G2gWPcK-yeAx1jz5Ln9_q=x9hMVjU=0zH8=dA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, Aug 9, 2025 at 3:06 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> Well, one benefit of trying to describe a complex system from the top
> is that higher level stupidity can sometimes become clear... I
> realised that the queue wouldn't even need to be initialised or
> cleared if StartReadBuffers() had an explicit in/out npinned argument
> to transmit the count between calls along with the buffers, or
> examined after each call. This is a draft alternative fix that I am
> studying that removes quite a lot of lines and fragility, though time
> is not on my side so I might push the one-liner fix ahead of the
> upcoming freeze and then see what to do about this.

One-liner fix pushed.

Here is a new version of the slightly more ambitious fix, for
discussion. I need to figure out if there is any measurable
performance impact, but from an interface sanity and fragility POV it
seems infinitely better like this. I recall being paranoid about
function call width, but it still fits in 6 registers. I think
perhaps the InvalidBuffer-based API might have seemed a shade more
reasonable before I reworked the pin limiting logic, but once I had to
start scanning for forwarded buffers after every StartReadBuffers()
call, I really should have reconsidered that interface. In other
words, maybe a bit of myopic path dependency here...

Attachment Content-Type Size
v2-0001-Give-StartReadBuffers-a-more-robust-interface.patch text/x-patch 16.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Merlin Moncure 2025-08-08 22:03:54 Re: Postgres: Queries are too slow after upgrading to PG17 from PG15