Re: Bug in logical decoding with DDL and subtransactions

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: "alvherre(at)kurilemu(dot)de" <alvherre(at)kurilemu(dot)de>
Cc: Bingshuai Li <lucian1412(at)outlook(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>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "mark(dot)dilger(at)enterprisedb(dot)com" <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>
Subject: Re: Bug in logical decoding with DDL and subtransactions
Date: 2026-10-14 07:16:01
Message-ID: CAFvd2n_OqoSR6mX2B7mL9+GVYvyLL9s_kLTm44Z0_8Oy8nhaPw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Oct 13, 2026 at 1:15 AM alvherre(at)kurilemu(dot)de
<alvherre(at)kurilemu(dot)de> wrote:
>
> Okay, I spent some more time trying to rewrite these comments in the new
> function so that they explain what we're doing in terms we use elsewhere
> in the code, and according to my understanding of how this works. The
> phrasing proposed by Bingshuai contains some terms that we don't use
> anywhere else, such as "a decoding pass" and other variations thereof,
> referring to the logical decoding "session". I would appreciate a
> review for correctness; if it's wrong, please propose fixes as minimal
> as possible (that is, not a complete rewrite).

Thanks for updating the comments.

They look good to me.

> By the way, the assurance that with this coding we will never call
> bsearch() with a NULL subxact array seems a bit too trusting ... I think
> we should just add the "return false" if nsubxacts == 0 in
> TransactionIdInSubxactArray() just to be on the safe side. It costs
> nothing.

+1

> (Well, nothing compared to the cost of doing a hash lookup for
> every single aborted subtransaction -- should we instead impose a cost
> on ReorderBufferBuildTupleCidHash?)

I think in most cases the hash lookup only happens once, for the primary XID -
we need to look up the other subxids only when the primary XID has no changes,
which I personally think is rare. And even in that case, we'd find the toplevel
transaction on the second lookup, for one of the subxids, unless many of the
subxids also have no changes. So the cost looks acceptable.

Best Regards,
Zhijie Hou

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-10-14 07:16:04 Re: Improving scalability of Parallel Bitmap Heap/Index Scan
Previous Message ZizhuanLiu X-MAN 2026-10-14 07:08:24 Re: Optimize MCV stats for sortable types and utilize sorted-order properties