Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uj9W4-003aNF-LU for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Aug 2025 04:43:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uj9W3-0076dr-4F for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Aug 2025 04:43:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uj9W2-0076dj-Ri for pgsql-bugs@lists.postgresql.org; Tue, 05 Aug 2025 04:43:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uj9W0-000nYC-0B for pgsql-bugs@lists.postgresql.org; Tue, 05 Aug 2025 04:43:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5754h693992761; Tue, 5 Aug 2025 00:43:06 -0400 From: Tom Lane To: Thomas Munro cc: Xuneng Zhou , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org, Michael Paquier Subject: Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer In-reply-to: References: <19006-80fcaaf69000377e@postgresql.org> Comments: In-reply-to Thomas Munro message dated "Tue, 05 Aug 2025 16:29:17 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <992759.1754368986.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 05 Aug 2025 00:43:06 -0400 Message-ID: <992760.1754368986@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro 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 =3D 0; i < stream->forwarded_buffers; ++i) + Assert(BufferGetBlockNumber(stream->buffers[stream->next_buffer_index += i]) =3D=3D + 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