pgsql: Fix REPACK decoding worker not cleaned up on FATAL exit

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix REPACK decoding worker not cleaned up on FATAL exit
Date: 2026-05-19 18:44:06
Message-ID: E1wPPQE-000IqK-00@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix REPACK decoding worker not cleaned up on FATAL exit

When the launching backend of REPACK (CONCURRENTLY) is terminated via
pg_terminate_backend(), ProcDiePending causes ereport(FATAL) which
bypasses PG_FINALLY blocks. As a result, stop_repack_decoding_worker()
is never called, leaving the decoding worker running indefinitely and
holding its temporary replication slot.

Fix by using PG_ENSURE_ERROR_CLEANUP, which handles both ERROR and
FATAL exits.

Author: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Reviewed-by: Sami Imseih <samimseih(at)gmail(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Discussion: https://postgr.es/m/CA+fm-RNoPxL2N7db_A0anMXV_aDu6jWj4PNOPtMtBUAPDPvSXQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0160143ad9a686a7e705348da1f90e63a2a31536

Modified Files
--------------
src/backend/commands/repack.c | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-05-20 06:57:52 pgsql: pg_recvlogical: Honor source cluster file permissions for output
Previous Message Alexander Korotkov 2026-05-19 10:55:08 pgsql: Clarify SPLIT PARTITION bound requirements in docs