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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Xuneng Zhou <xunengzhou@gmail.com>, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org, Michael Paquier <michael@paquier.xyz>
Date: 2025-08-05T04:43:06Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix rare bug in read_stream.c's split IO handling.

Thomas Munro <thomas.munro@gmail.com> writes:
> Here's my proposed fix.  Great reproducer, Alexander, thanks!

I've not looked at the issue actually being fixed, but a drive-by
comment: these loops

+	for (int i = 0; i < stream->forwarded_buffers; ++i)
+		Assert(BufferGetBlockNumber(stream->buffers[stream->next_buffer_index + i]) ==
+			   stream->pending_read_blocknum + i);

should be wrapped in "#ifdef USE_ASSERT_CHECKING".  Maybe the
compiler is smart enough to throw away the useless looping logic
in a production build, or maybe it isn't.

			regards, tom lane