Re: Bug in logical decoding with DDL and subtransactions

From: Rajesh Kumar Thandapani <rajeshkumarth(at)google(dot)com>
To: Manu <manuelreyesbravo(at)gmail(dot)com>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: alvherre(at)kurilemu(dot)de, Bingshuai Li <lucian1412(at)outlook(dot)com>, Zhijie Hou <houzhijie22(at)gmail(dot)com>, Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Bug in logical decoding with DDL and subtransactions
Date: 2026-11-23 09:46:45
Message-ID: CAJoZ81vgp9jfqV+9Bf=tQ1COPQEfaLzgG5gJO6-zmbVcBaSRoQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Oct 17, 2026 at 12:02 PM Manu <manuelreyesbravo(at)gmail(dot)com> wrote:
> One thing worth documenting: the guard relies on the catalog-changes flag
> never being cleared once set. That holds today, but a short comment or an
> Assert at the skip would make the dependency explicit for whoever adds a
> flag path later.

Hi Manu, Ayush,

Since this did not seem to get picked up as a formal patch yet, I put
together a v1 patch (attached) building on Ayush's snippet and your
feedback.

On top of the earlier snippet, it also returns early when
toptxn->tuplecids is already empty (so pure DML transactions avoid the
subxacts[] lookups), adds an Assert in ReorderBufferAddNewTupleCids()
that subxid has RBTXN_HAS_CATALOG_CHANGES set, and adds the
tuplecid_nested.spec permutation with a regular write in the outer
savepoint.

On an assert-enabled build of master, decoding a transaction with 50,000
catalog tuplecids followed by 5,000 rolled-back DML subtransactions drops
from ~2310 ms to ~104 ms, and all test_decoding tests pass.

Regards,
Rajesh Kumar Thandapani

Attachment Content-Type Size
v1-0001-Skip-tuplecid-cleanup-scan-when-aborted-subxacts-.patch application/x-patch 6.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-11-23 09:51:37 Re: log_postmaster_stats
Previous Message Andreas Karlsson 2026-11-23 09:44:05 Re: Proposal: ABSENT ON TRAILING NULL for JSON_ARRAY