Bug in logical decoding with DDL and subtransactions

From: Bingshuai Li <lucian1412(at)outlook(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: "mark(dot)dilger(at)enterprisedb(dot)com" <mark(dot)dilger(at)enterprisedb(dot)com>
Subject: Bug in logical decoding with DDL and subtransactions
Date: 2026-08-12 03:39:19
Message-ID: ME0P300MB05683BB56ADC31410D668339C6DC2@ME0P300MB0568.AUSP300.PROD.OUTLOOK.COM
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Mark,

Here is a v2 of the abort-time cleanup patch. The code changes are
identical to v1; there are two test-related fixes:

- the new regression test is now also registered in
contrib/test_decoding/meson.build -- v1 added it to the Makefile
only, so Meson builds would not have run it;
- the test no longer hardcodes the regression database name when
reconnecting to drop its scratch database (make and Meson use
different names, which broke the test's final reconnect under
Meson).

Re-verified on master (36f7330b8b2, --enable-cassert): the
test_decoding suite (21 regression + 14 isolation tests, including
tuplecid) passes under both build systems, and the core regression
suite passes (245/245).

One trade-off worth stating explicitly: ReorderBufferAbort() now
scans the toplevel transaction's tuplecids list, an O(N) walk per
aborted subtransaction. I believe that is acceptable for a
backpatchable fix -- catalog-modifying subtransaction aborts are
rare, and each removal shortens the list. The cleaner long-term
design (queue tuplecids on the writing subtransaction and merge at
commit) is a much larger change and should not block this fix.

The test considerations from my previous mail still apply: it is
probabilistic in principle, and it cannot observe the silent
corruption on non-assert builds. And as before, I'm not attached to
either approach -- the goal is to get this fixed for 19.

Thanks,
Bingshuai Li

Attachment Content-Type Size
v2-0001-Fix-stale-tuplecid-records-left-behind-by-aborted.patch application/octet-stream 24.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Haibo Yan 2026-08-12 04:00:41 [PATCH] Remove redundant ORDER BY from COUNT aggregates
Previous Message Shinya Kato 2026-08-12 03:37:34 Re: Avoid recalculating pgprocno in ProcArrayAdd()