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

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(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-13 01:30:00
Message-ID: CALj2ACU6BY=WyWJtqLUBx5+tYUXqi+cGVfg7kdqyKC5WngES4w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Aug 10, 2026 at 11:16 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> > I will drop both asserts and
> > keep a short comment explaining why the slot is still held here. The
> > existing AtEOSubXact_LargeObject() and AtEOSubXact_Files() don't check
> > the passed-in mySubid for invalid either.
> >
> > Does the following work for you?
> >
> > /*
> > * The aborting subxact is the one that acquired the slot, so the slot is
> > * still held and must be released. acquiredInSubId is set only when a slot
> > * is held and cleared when it is released, so a matching subxact id means
> > * the slot is ours.
> > */
> > ReplicationSlotRelease();
>
> I am okay with this comment. No 'MyReplicationSlot-null' check and no assert.

Thanks. Done so in the attached v12 patch. Please have a look.

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

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-08-13 01:47:24 Re: Fix detection of truncated zstd-compressed backups
Previous Message Peter Smith 2026-08-13 01:11:11 Re: DOCS - ALTER PUBLICATION - description has confusing slash-list