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.96) (envelope-from ) id 1wUF2d-00122I-1o for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2026 02:39:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUF2c-00CICI-0o for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2026 02:39:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUF2b-00CICA-2g for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 02:39:41 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wUF2Z-00000000mBz-1xwA for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 02:39:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1780367978; bh=Ri+R4ei0kVPttlx+N6lSR2qpoC3uYyj8fj7P/YnGu3g=; h=From:Message-Id:Subject:Date:In-Reply-To:Cc:To:References:From; b=jhpTA9BYjhIofYmzJ73JFymdEb2e6lHX+4YA1kDNAzWzHsEni6hwSqWQk1sc11r8P R8o0uksAdf44rmqBd5bM4LqISVSO1rmGSipII69twazZOyfk/yyjEgifrRCXjRk48I lCFylL0PpggW39HwUqwHtzdgaPvQUcfvZVpM0FW5WuYglAMbTgHrYy+7m6GYAIciq1 17pnHktyw6WAn0qMLDjWxsrro2Wb8PqOD65n8CEPsDXzH6pHRf+3BOVaF5IXCbw2Ro OUFv6YNyuOdSWXKLQ+x7oJ1W3mek5jDGV6LwWCmO3ZEjMEN0jiZfAwL5t6qSCyOo1D zjzu+8f4FgERQ== Received: from smtpclient.apple (unknown [109.195.36.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: n.kalinin@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id A86615FE1E; Tue, 2 Jun 2026 05:39:37 +0300 (MSK) From: =?utf-8?B?0J3QuNC60LjRgtCwINCa0LDQu9C40L3QuNC9?= Message-Id: <98783F14-E583-4CFB-9AE0-7B3945449724@postgrespro.ru> Content-Type: multipart/alternative; boundary="Apple-Mail=_D2F57EA2-76A7-40E7-97C3-08C2CDB3BCFD" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: BUG #19500: pgrepack logical decoding plugin can crash assert builds via SQL decoding API Date: Tue, 2 Jun 2026 09:39:26 +0700 In-Reply-To: Cc: pgsql-bugs@lists.postgresql.org, Antonin Houska , b@ida.kurilemu.internal To: =?utf-8?Q?=C3=81lvaro_Herrera?= References: X-Mailer: Apple Mail (2.3864.600.51.1.1) X-KSMG-AntiPhishing: NotDetected, bases: 2026/06/02 02:11:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 3.0.0.9059, bases: 2026/06/02 01:38:00 #28207750 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_D2F57EA2-76A7-40E7-97C3-08C2CDB3BCFD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 2 Jun 2026, at 00:12, =C3=81lvaro Herrera = wrote: >=20 > How about something like this? It makes your test case throw an error > instead of failing the assertion, which I suppose is an improvement. >=20 > The patch is a bit noisy because I moved more code than the minimum > necessary; but the gist of it is that we allocate RepackDecodingState = in > repack_startup(), then have repack_setup_logical_decoding() fill in a > magic number, which we later check in repack_begin_txn(). This is a = bit > wasteful, because we have to do that check once for each and every > transaction; however I see no other callback that would let us do this > kind of check after the slot is created but before we start to consume > from it. >=20 > --=20 > =C3=81lvaro Herrera 48=C2=B001'N 7=C2=B057'E =E2=80=94 = https://www.EnterpriseDB.com/ > "Before you were born your parents weren't as boring as they are now. = They > got that way paying your bills, cleaning up your room and listening to = you > tell them how idealistic you are." -- Charles J. Sykes' advice to = teenagers > <0001-Have-RepackDecodingState-carry-a-magic-number.patch> Yes, I agree that returning an error to the user makes sense.=20 But does the error message need to be that detailed? Perhaps something = like "ERROR: wrong magic number in "pgrepack" decoder plugin" would be sufficient. Nevertheless, I tested the patch and can confirm that there are no = assertion failures anymore.=20 I also ran it under ASAN and did not observe any issues. Would it make sense to add a test for this case from the bug report? --Apple-Mail=_D2F57EA2-76A7-40E7-97C3-08C2CDB3BCFD Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On 2 = Jun 2026, at 00:12, =C3=81lvaro Herrera <alvherre@kurilemu.de> = wrote:

How about something like this?  It makes = your test case throw an error
instead of failing the assertion, which = I suppose is an improvement.

The patch is a bit noisy because I = moved more code than the minimum
necessary; but the gist of it is = that we allocate RepackDecodingState in
repack_startup(), then have = repack_setup_logical_decoding() fill in a
magic number, which we = later check in repack_begin_txn().  This is a bit
wasteful, = because we have to do that check once for each and every
transaction; = however I see no other callback that would let us do this
kind of = check after the slot is created but before we start to consume
from = it.

--
=C3=81lvaro Herrera =             &n= bsp; 48=C2=B001'N 7=C2=B057'E  =E2=80=94 =  https://www.EnterpriseDB.com/
"Before you were born your = parents weren't as boring as they are now. They
got that way paying = your bills, cleaning up your room and listening to you
tell them how = idealistic you are."  -- Charles J. Sykes' advice to = teenagers
<0001-Have-RepackDecodi= ngState-carry-a-magic-number.patch>

Yes, I agree that = returning an error to the user makes sense. 

But does the error message need to be that detailed? = Perhaps something like

"ERROR: wrong magic number in "pgrepack" decoder =
plugin"
=

would be sufficient.

Nevertheless, I tested the patch and can confirm that = there are no assertion failures anymore. 

I also ran it under ASAN and did not observe any = issues.

Would it make sense to = add a test for this case from the bug report?


= --Apple-Mail=_D2F57EA2-76A7-40E7-97C3-08C2CDB3BCFD--