| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix assertion after aborting internal subtransaction at transact |
| Date: | 2026-09-17 05:30:46 |
| Message-ID: | E1x74hq-0000000041e-0zG6@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix assertion after aborting internal subtransaction at transaction end
Previously, aborting an internal subtransaction during COMMIT or
PREPARE TRANSACTION could cause the following assertion failure.
This could happen, for example, when a deferred constraint trigger fired
at COMMIT and its PL/pgSQL exception block caught an error raised
while executing the trigger function.
TRAP: failed Assert("s->blockState == TBLOCK_SUBINPROGRESS || s->blockState
== TBLOCK_INPROGRESS || s->blockState == TBLOCK_IMPLICIT_INPROGRESS ||
s->blockState == TBLOCK_PARALLEL_INPROGRESS || s->blockState ==
TBLOCK_STARTED"), File: "xact.c", Line: 4851, PID: 73455
An internal subtransaction should be able to be aborted while the parent
transaction is in the COMMIT or PREPARE TRANSACTION phase. However,
RollbackAndReleaseCurrentSubTransaction()'s assertion check previously
did not allow TBLOCK_END and TBLOCK_PREPARE as parent transaction
states, causing the assertion failure.
This commit fixes the assertion check by allowing those two parent
transaction states.
Backpatch to all supported versions.
Reported-by: Fabrízio de Royes Mello <fabrizio(at)planetscale(dot)com>
Author: Patrick Reynolds <piki(at)planetscale(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Fabrízio de Royes Mello <fabrizio(at)planetscale(dot)com>
Discussion: https://postgr.es/m/CABo-N97AeMbWuYTWg-3%3D2DkTR3EkvS%2BFt%3DyEaWB181STsR1mBg%40mail.gmail.com
Backpatch-through: 14
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/aad2baff0eef8874af46877120811896017654f3
Modified Files
--------------
src/backend/access/transam/xact.c | 2 ++
src/test/regress/expected/triggers.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql | 25 +++++++++++++++++++++++++
3 files changed, 55 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Korotkov | 2026-09-17 06:36:20 | pgsql: doc: Explain when to use the WAIT NO_THROW option |
| Previous Message | Fujii Masao | 2026-09-17 05:30:34 | pgsql: Fix assertion after aborting internal subtransaction at transact |