Re: [PATCH] Release a replication slot leaked by a caught subtransaction error

From: Bryan Green <dbryan(dot)green(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Release a replication slot leaked by a caught subtransaction error
Date: 2026-08-09 03:54:51
Message-ID: ec681f6e-d4fc-4542-a954-6d550b61c3ae@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/8/26 22:46, Bharath Rupireddy wrote:
> Hi,
>
> On Sat, Aug 8, 2026 at 8:33 PM Bryan Green <dbryan(dot)green(at)gmail(dot)com> wrote:
>>
>> A SQL slot function that errors after acquiring MyReplicationSlot leaks the
>> slot when the error is caught by a PL/pgSQL EXCEPTION handler: the
>> subtransaction aborts without releasing it, MyReplicationSlot stays set, and
>> the next slot operation in the session trips Assert(!MyReplicationSlot).
>>
>> Releasing on error is done at the top level, in PostgresMain(), and the
>> comment there is explicit that AbortTransaction() must not do it:
>
> Thanks. This issue is being discussed in this thread:
> https://www.postgresql.org/message-id/CALj2ACU-mVxrak_Q0EP1sZg8h%3D7pg1d09Gj6Ody5jH6zxiZQLA%40mail.gmail.com.
>
Apologies for missing this. I will catch up on this thread! Thanks for
bringing it to my attention!

--
Bryan Green
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2026-08-09 04:38:33 [PATCH] Make select_views regression test output deterministic
Previous Message Bryan Green 2026-08-09 03:47:26 [PATCH] Fix TOCTOU races in recovery/t/020_archive_status.pl archive checks