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

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Bryan Green <dbryan(dot)green(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:46:30
Message-ID: CALj2ACV++HarY9yxR-dKdxqgNSsjUv73uLrBJBFVtKZ9_7y8Ag@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2026-08-09 03:47:26 [PATCH] Fix TOCTOU races in recovery/t/020_archive_status.pl archive checks
Previous Message Bryan Green 2026-08-09 03:44:50 [PATCH] Harden recovery/t/051_effective_wal_level against WAL recycling