Re: Bug in logical decoding with DDL and subtransactions

Started by Rajesh Kumar Thandapani6 days ago1 messageshackers

Thread notes

1 note#bug
hackorum-bot#bug
hackorum-bot
2 days ago

@global #bug

#bug
Jump to latest
#1Rajesh Kumar Thandapani
rajeshkumarth@google.com

On Sat, Oct 17, 2026 at 12:02 PM Manu <manuelreyesbravo@gmail.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

Attachments:

t259657_1
v1-0001-Skip-tuplecid-cleanup-scan-when-aborted-subxacts-.patchapplication/x-patch; name=v1-0001-Skip-tuplecid-cleanup-scan-when-aborted-subxacts-.patchDownload+58-1