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 1wSPEk-003A8e-2K for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 01:08:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSPEg-00AW11-3D for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 01:08:35 +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.96) (envelope-from ) id 1wSPEg-00AW0t-1j for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 01:08:35 +0000 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wSPEf-000000015u5-3Kfp for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 01:08:34 +0000 Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-63129bf2af0so4621688137.2 for ; Wed, 27 May 2026 18:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779930513; cv=none; d=google.com; s=arc-20240605; b=F5HjAWWq6e3QQyP4ZhPuV7FwDPGFJuWQmIgyRmKs0FrLqJDmNBVh0fFgPuXOykLeFY 2Py1sFDHzmKQfYvJTAxmC6o+xnK4v4qh9MYR1oi1VTiNeAJeQabKA9sVwYkaVO76m511 vatn/IqQqRaNI0QcTD82apKHZpt9xEeTblVh0h0HhSg8xIrLC8nRaay/HopXPGSNpWn1 w+mXO471GPu9BkBOaSTDTgXtmq/8Rpz35Cud0JMDw2CijSSLRMh5jdIptARX4Qn4izz3 00H/aAF9ZvrRoyuW6kUbjCVhYJv9/tLkju++HD/llE8QKYOCQMLhdjfE87LsQJLuN7ge 8iTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=p+aR+RhIOQo6szGL1dmLK+CZrTLRSm4c88jlNeCca+k=; fh=OUQ0FSXLM0Ecc8/WFx1p30hlwR0FxxQYrP8qt1azuBg=; b=GSgh+9yuRMu3ocJ9ARAD1zLMmprrttgqiFh0PJSb21yRNdYPe6P/tGQEB2vh3dcJdo PgjsrFP5btlnfB9aAOjqHyyXP4X+VE92geyd7iY+0R5qJHBUZFL2fk+JvyesLRHIyCLN owz713mbXvq8vXF1zxf0PYEBUlh7Q4jDLH1Pr5Td33ZF2YdRSwRuZ/UpN0wTz77wWdSl S95McmBiUUthU5DOaZO72OYY7iMWorbOYqadiZGplKOUxlIeOW49nt+cNWTOSvQWvZRo qpt0et7vmm8YB5V5JXHwyCcMx/gWypCVAnVPTmk47HbRPhQNOkMJXfGCkTHKKJxL1W/B xwhw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779930513; x=1780535313; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=p+aR+RhIOQo6szGL1dmLK+CZrTLRSm4c88jlNeCca+k=; b=UIQyAlpJRwcWrkpTrowKIG2lRg7FhViuMwuAcGW/awDuZRtp0wEIKarPPpCCeXAPfm SPnlXG5XRWv4AJF/kWGgiEUuq0Eoot3xSHfS5mg5EdyOMWpIuUOp/qsWeXN5lMYGhCOR TRSHq8dqYLGDBho8Lmemj303JDj0diUvhstY30/k0qS60Wt+uFeF8qFlerLZg+MKONdx l1BJcOkg1brICB6SHgMqWcHraI13jTcMVF+X3S0gAJ4hAItxooc5yNUbZDOFuChyeSMn c2zuP9KjeCpCmepxkBQt7sJOuP+Bfej+rPt6n8XZ3RXi/dNYOwzXGo6fEcKFvpWITRHT ypyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779930513; x=1780535313; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=p+aR+RhIOQo6szGL1dmLK+CZrTLRSm4c88jlNeCca+k=; b=WHGJf8gCOgiAKlsxcHM+cD+IqaciB59I/xtVvbz32s5BexTcG4pD6tdyk63cSjfHh2 ui3VTYKxrqutkvAc8RO5mgqQLRW88KTvJ+A/lcu4Z8K8hnt0P9wMbCitdkcTmafh9QbN 89Qubnl/7ODhNB4LbgHuFupEt/XrEJ+hYINlZV60ZOLn4o0NQb16/0Q0Q6HowX+BGXcY m0kkXDNfGIpRZ6t/n3UEiFC95Zxh/RNEmbSr7GjunQlaUWxQAmGwshbBhRS4JTnXS/lQ gtSJM/T1vBYVkQ4e5suroL3Y58nygvfjwlTEnawHYIFH1+Sg7pLorA0go/xIGaca2YKK AXwA== X-Forwarded-Encrypted: i=1; AFNElJ+BEbJpKVVOIKXJfAjj42puZpPVHXoShdh0POOf1r2rJIVGeVzgpREbBNXwvLdMf6QU+Ybopu+U/JcaUEBi@lists.postgresql.org X-Gm-Message-State: AOJu0YwSM3+j0WDF67cnEWTqIin7UJqARkisjgmym+1NuDN1FQIbyg0j akVRri1ixXiu9onzC8h1Ey+RC4itrGmbH2TWLugXmrrEwe0R6QkKt+SDmEJM6X8bd4HwclDrlQY UV+/+gUPboVSTgJ7L2iL6kDFqw3xeY5g= X-Gm-Gg: Acq92OH+aLDXa3eeh0RqlvXWtnBVJ9feEKEGcoQyj/2KT2z3lhuC1ndaH8K0czVFpIq qzca/blc5nVhW90rI+ck3/NpOHzB40dkr5TQJHIHmgiSKOQkk1f/odzR3D0P00TrjqwreOh4wlF GNOQA5IqgOepRwwjLMq5lMqMAgZZLSGJm6k9rUsZwmYxoBaNz+dkyq71ZORSRcvbnhxKQw+9+2w RgWbMkQgLxpk/N5elo0j1wPkSUTQH33hLhmysx+EN2s8Y0W5veBEBJVtgamh4hibWh/h43ANFhF A2cVAW8j8KcQKOL+xg== X-Received: by 2002:a05:6102:370e:b0:632:29a5:2b27 with SMTP id ada2fe7eead31-67c7151c86bmr13361634137.3.1779930512551; Wed, 27 May 2026 18:08:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: SATYANARAYANA NARLAPURAM Date: Wed, 27 May 2026 18:08:21 -0700 X-Gm-Features: AVHnY4IvOnAhTM5EUgRdaCaPAKeteSE2yA7TpYuqsfr-9IqxCmJITCOFaHUzSYs Message-ID: Subject: Re: [PATCH] Release replication slot on error in SQL-callable slot functions To: Fujii Masao Cc: shveta malik , vignesh C , PostgreSQL Hackers , shveta malik Content-Type: multipart/alternative; boundary="000000000000ecf5090652d65df2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ecf5090652d65df2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Wed, May 27, 2026 at 1:12=E2=80=AFAM Fujii Masao = wrote: > On Wed, May 27, 2026 at 1:31=E2=80=AFPM SATYANARAYANA NARLAPURAM > wrote: > > Thank you for the changes and review. > > When I applied the v4 patch together with Shveta's diff patch and > ran the regression tests, the tests failed. > > Could pg_create_physical_replication_slot() still have the same issue > if it throws an error after ReplicationSlotCreate() and that error is > caught by a PL/pgSQL EXCEPTION block > Also, do maybe pg_copy_physical_replication_slot(), > pg_drop_replication_slot(), > and ALTER_REPLICATION_SLOT potentially have the same issue as well? > Addressed these in v5 patch, will send out shortly. ALTER_REPLICATION_SLOT is not exploitable by a SQL query though it has a similar signature. A walsender error terminates the session so there is no session to leave in a bad state. --000000000000ecf5090652d65df2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Wed, May 27, = 2026 at 1:12=E2=80=AFAM Fujii Masao <masao.fujii@gmail.com> wrote:
On Wed, May 27, 2026 at 1:31=E2=80=AFPM SATYANAR= AYANA NARLAPURAM
<satyanar= lapuram@gmail.com> wrote:
> Thank you for the changes and review.

When I applied the v4 patch together with Shveta's diff patch and
ran the regression tests, the tests failed.

Could pg_create_physical_replication_slot() still have the same issue
if it throws an error after ReplicationSlotCreate() and that error is
caught by a PL/pgSQL EXCEPTION block

Also, do maybe pg_copy_physical_replication_slot(), pg_drop_replication_slo= t(),
and ALTER_REPLICATION_SLOT potentially have the same issue as well?

Addressed these in v5 patch, will send out sho= rtly. ALTER_REPLICATION_SLOT=C2=A0
is not exploitable=C2=A0by a S= QL query though it has a similar signature.
A walsender error ter= minates the session so there is=C2=A0no session to leave in a=C2=A0bad stat= e.
--000000000000ecf5090652d65df2--