| From: | Manu <manuelreyesbravo(at)gmail(dot)com> |
|---|---|
| To: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
| Cc: | "alvherre(at)kurilemu(dot)de" <alvherre(at)kurilemu(dot)de>, Bingshuai Li <lucian1412(at)outlook(dot)com>, Zhijie Hou <houzhijie22(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>, "a(dot)kozhemyakin(at)postgrespro(dot)ru" <a(dot)kozhemyakin(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Bug in logical decoding with DDL and subtransactions |
| Date: | 2026-10-17 12:02:49 |
| Message-ID: | 179223856913.4155965.12786541965300839444@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ZizhuanLiu X-MAN | 2026-10-17 12:06:09 | Re: Optimize MCV stats for sortable types and utilize sorted-order properties |
| Previous Message | Manu | 2026-10-17 11:55:29 | Re: pg_upgrade stores an invalid datminmxid/relminmxid when the old cluster's newest multixact is 0xFFFFFFFF |