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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Xuneng Zhou <xunengzhou(at)gmail(dot)com>, exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer
Date: 2025-08-06 08:40:33
Message-ID: aJMVAbYRcdImR3-V@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Aug 05, 2025 at 12:43:06AM -0400, Tom Lane wrote:
> 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.

I'd bet it is usually not that smart.. Embedding these in an extra
#ifdef is a sound defense IMO.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Etsuro Fujita 2025-08-06 11:30:41 Re: TRAP: failed Assert("outerPlan != NULL") in postgres_fdw.c
Previous Message Dilip Kumar 2025-08-06 06:08:44 Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database