From: Manu <manuelreyesbravo@gmail.com>
To: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Cc: alvherre@kurilemu.de <alvherre@kurilemu.de>
Cc: Bingshuai Li <lucian1412@outlook.com>
Cc: Zhijie Hou <houzhijie22@gmail.com>
Cc: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: Mark Dilger <mark.dilger@enterprisedb.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Andrey Rachitskiy <pl0h0yp1@gmail.com>
Cc: a.kozhemyakin@postgrespro.ru <a.kozhemyakin@postgrespro.ru>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Bug in logical decoding with DDL and subtransactions
Date: Sat, 17 Oct 2026 09:02:49 -0300
Message-ID: <179223856913.4155965.12786541965300839444@gmail.com> (raw)
In-Reply-To: <CAJTYsWXAQmRfNi1zg7-yeuMc56yeOkq22eyxDiQa_Q+2tD+sGg@mail.gmail.com>
References: <CAJTYsWXAQmRfNi1zg7-yeuMc56yeOkq22eyxDiQa_Q+2tD+sGg@mail.gmail.com>
Hi Ayush,
> Could we skip that scan when none of the aborting xids has catalog
> changes? [...] I can prepare a patch if the direction looks right.
The direction looks right. I built your guard on current master
(26bd08fb5c, which has beff3cd0098) and measured it:
- Correctness: across 60,000 random transactions (DDL plus DML, nested
savepoints with RELEASE, and a DML-only savepoint rolled back after the
DDL), the build with your guard decoded byte-for-byte the same stream as
master. I also instrumented the skip path to walk the list anyway and
count what it would have removed: in 50,287 skipped aborts, 0 had any
tuplecid to remove.
- The loop over the subxacts is necessary, as you noted. Without it, a
tuplecid_nested permutation with an INSERT at the outer savepoint (the
outer subxact has no catalog changes of its own; the entries belong to a
released inner subxact) fails on the cmin Assert, and the same thing
crashes the differential fuzzer in every shard. With the loop, all of it
passes. (ReorderBufferBuildTupleCidHash() already gates on
rbtxn_has_catalog_changes() the same way; the flag is set in
ReorderBufferXidSetCatalogChanges() and cleared nowhere, so it is a sound
gate here too.)
- Saving: it grows as (tuplecid list length) x (DML-only aborts). For short
lists it is in the noise -- around 0.1 ms at 1k tuplecids and 100 aborts.
It becomes real higher up: 10k/1k is 19 ms -> 3.6 ms, 50k/10k is
1067 ms -> 18 ms, and 100k/10k is 5213 ms -> 36 ms.
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.
Happy to share the extra test permutation and the fuzz/benchmark scripts if
they are useful for the patch.
Regards,
Manu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: manuelreyesbravo@gmail.com, ayushtiwari.slg01@gmail.com, alvherre@kurilemu.de, lucian1412@outlook.com, houzhijie22@gmail.com, kuroda.hayato@fujitsu.com, michael@paquier.xyz, tgl@sss.pgh.pa.us, exclusion@gmail.com, mark.dilger@enterprisedb.com, amit.kapila16@gmail.com, sawada.mshk@gmail.com, pl0h0yp1@gmail.com, a.kozhemyakin@postgrespro.ru
Subject: Re: Bug in logical decoding with DDL and subtransactions
In-Reply-To: <179223856913.4155965.12786541965300839444@gmail.com>
References: <CAJTYsWXAQmRfNi1zg7-yeuMc56yeOkq22eyxDiQa_Q+2tD+sGg@mail.gmail.com> <179223856913.4155965.12786541965300839444@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox