pgsql: Fix deferred XLogLogicalInfo update after a failed transaction b

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix deferred XLogLogicalInfo update after a failed transaction b
Date: 2026-10-06 17:01:42
Message-ID: E1xE8Xu-00000000Zp7-2BlQ@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix deferred XLogLogicalInfo update after a failed transaction block.

Previously, a backend with an assigned XID deferred the
XLogLogicalInfo update requested by a procsignal barrier, and we
applied it in AbortTransaction() on abort. However, a failed
transaction block keeps its XID until ROLLBACK, so a barrier absorbed
while idle in that state was deferred, and CleanupTransaction() did
not apply it. The next transaction then ran entirely with the stale
value. If logical decoding had just been enabled, that transaction's
changes were written without logical information and silently skipped
by decoding.

Fix by applying the pending update in CleanupTransaction() instead of
AbortTransaction(). We call it after resetting the top-level XID
because, unlike the commit and prepare paths, CleanupTransaction()
isn't always called with interrupts held, so a barrier absorbed before
the reset would be deferred again and carried into the next
transaction.

Patch by Sergei Patiakin, with tests added by me.

Oversight in commit 67c20979ce7.

Reported-by: Sergei Patiakin <sergei(dot)patiakin(at)enterprisedb(dot)com>
Author: Sergei Patiakin <sergei(dot)patiakin(at)enterprisedb(dot)com>
Reviewed-by: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Reviewed-by: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Discussion: https://postgr.es/m/CANE55rApeNAFaqxLWrvm-NC0Y5gkrBFZFVaHVYP89AGS2SYMcA@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a80744949ca065d0e21998344aabaa803c02713d

Modified Files
--------------
src/backend/access/transam/xact.c | 12 ++++++++++-
src/backend/replication/logical/logicalctl.c | 6 +++++-
src/test/recovery/t/051_effective_wal_level.pl | 30 ++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-06 19:08:06 pgsql: Doc: correct overambitious precision claim for contrib/seg.
Previous Message Masahiko Sawada 2026-10-06 17:01:37 pgsql: Fix deferred XLogLogicalInfo update after a failed transaction b