From: Michael Paquier <michael@paquier.xyz>
To: Manu <manuelreyesbravo@gmail.com>
Cc: Zhijie Hou <houzhijie22@gmail.com>
Cc: shihao zhong <zhong950419@gmail.com>
Cc: Takeshi Ideriha <iderihatakeshi@gmail.com>
Cc: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Cc: alpkeles99@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction
Date: Tue, 27 Oct 2026 08:34:41 +0900
Message-ID: <at_jkYo3RL5qszzF@paquier.xyz> (raw)
In-Reply-To: <179302927929.1603125.13910327766898839560@gmail.com>
References: <at6lcAt8xkkuUKSm@paquier.xyz>
<179302927929.1603125.13910327766898839560@gmail.com>
On Mon, Oct 26, 2026 at 12:41:19PM -0300, Manu wrote:
> Thanks for taking care of it. The attached series adds the second
> spot on top of e7f4463e869, as shihao asked upthread.
>
> + /*
> + * If the updater of the tuple has already aborted (a rolled-back
> + * subtransaction of the inserter), remember that, as callers like
> + * rewriteheap.c rely on HEAP_XMAX_INVALID to tell a live tuple
> + * from an updated one.
> + */
> + if (!(tuple->t_infomask & HEAP_XMAX_INVALID) &&
> + !(tuple->t_infomask & HEAP_XMAX_IS_MULTI) &&
> + !HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask) &&
> + !HeapTupleHeaderIsOnlyLocked(tuple))
> + {
> + TransactionId xmax = HeapTupleHeaderGetUpdateXid(tuple);
> +
> + /*
> + * xmax == xmin: xmax is in progress too, nothing to do.
> + * The clog is only a cheap filter here: a running xmax is not
> + * aborted there. An abort reaches the clog before the xid
> + * leaves the proc array, and the new version of the tuple,
> + * whose xmin is this xmax, is in progress until then. So the
> + * proc array must confirm it, as the note at the top of this
> + * file asks.
> + */
> + if (!TransactionIdEquals(xmax, HeapTupleHeaderGetRawXmin(tuple)) &&
> + TransactionIdDidAbort(xmax) &&
> + !TransactionIdIsInProgress(xmax))
> + SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
> + InvalidTransactionId);
> + }
FWIW, this does not feel right. Your patch is a gathering of
everybody's suggestions that have been fed to an LLM, without thinking
through the problem, resulting of a pile of changes which was itself a
pile of changes. I'd suggest to take three deep breaths and not rely
on an LLM to try to think through all the potential holes that any of
the previous suggestions have. Piling workarounds on top of
workarounds is no good for these code paths. They just become more
complicated to think about long-term.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
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-bugs@postgresql.org
Cc: michael@paquier.xyz, manuelreyesbravo@gmail.com, houzhijie22@gmail.com, zhong950419@gmail.com, iderihatakeshi@gmail.com, ayushtiwari.slg01@gmail.com, alpkeles99@gmail.com
Subject: Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction
In-Reply-To: <at_jkYo3RL5qszzF@paquier.xyz>
References: <at6lcAt8xkkuUKSm@paquier.xyz> <179302927929.1603125.13910327766898839560@gmail.com> <at_jkYo3RL5qszzF@paquier.xyz>
* 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