Re: [PATCH] Release replication slot on error in SQL-callable slot functions

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Release replication slot on error in SQL-callable slot functions
Date: 2026-08-31 20:47:00
Message-ID: CALj2ACW2fhPbVhKOcz_pmzspXif8J2W9O=rwX0dXc5OSCn87OQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sun, Aug 30, 2026 at 9:40 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> > Hi Amit, By restricting in the code, does that mean adding an Assert,
> > or a WARNING, or a WARNING plus slot release (not an error), in the
> > replication slot subxact callback on the commit path, instead of
> > handing the slot off to the parent across the subtransaction boundary?
>
> Yes, I would prefer WARNING similar to existing cases for resource
> leaks in commit paths. One example of a similar existing case is:
> ------
> /* Complain if any allocated files remain open at commit. */
> if (isCommit && numAllocatedDescs > 0)
> elog(WARNING, "%d temporary files and directories not closed at
> end-of-transaction",
> numAllocatedDescs);
> -------
>
> Based on above, I am imagining a check/WARNING on lines of:

Thanks, Amit. That works for me. Please find the attached v15 patch.
If it looks good, I can prepare patches for the back branches.

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v15-0001-Fix-replication-slot-leak-on-error-caught-in-a-s.patch application/octet-stream 15.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-08-31 20:50:34 Re: REPACK (CONCURRENTLY) fails with wrong error for materialized views
Previous Message Álvaro Herrera 2026-08-31 20:41:37 Re: REPACK (CONCURRENTLY) fails with wrong error for materialized views