From: Michael Paquier <michael@paquier.xyz>
To: Takeshi Ideriha <iderihatakeshi@gmail.com>
Cc: shihao zhong <zhong950419@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, 20 Oct 2026 16:54:30 +0900
Message-ID: <atceNofaGIE2dOFn@paquier.xyz> (raw)
In-Reply-To: <atcbPTfcO9rihmbD@paquier.xyz>
References: <19760-8f9a0eba17bc8c92@postgresql.org>
<41175da6-293f-4b8f-ad18-3636f3d8a2f6@gmail.com>
<CAJTYsWXQgkqEpecZK9MCFVV+504oOdueuenRf+xTfNf9BcKE-g@mail.gmail.com>
<CAGRkXqRMvz-ZzC88_eXsyJZRpPXhE4_Fo6ueYdm5tpH+CHc6EQ@mail.gmail.com>
<5fff280b-96c4-497f-bbfc-0af95b9844b3@gmail.com>
<CAGRkXqSo9vZ=7mw_X0tjH1-Wwdz8nWu9xpdX1x8hVM8tCazKAA@mail.gmail.com>
<949ad7b3-2b0e-40dc-b6ac-e84da432149b@gmail.com>
<atcbPTfcO9rihmbD@paquier.xyz>
On Tue, Oct 20, 2026 at 04:41:49PM +0900, Michael Paquier wrote:
> Having a recheck of the old tuple's state within
> rewrite_heap_dead_tuple() feels very incorrect to me, based on the
> bunch of comments at the top of rewriteheap.c. It sounds to me that
> rewrite_heap_dead_tuple() should be called when we know that the tuple
> is dead, no? Isn't heapam_relation_copy_for_cluster() the bit actually
> incorrect here, marking the tuple with "isdead" to start with? Your
> solution of a recheck to make sure that an old tuple is actually dead
> in a code path where an old tuple is assumed to be absolutely and
> definitely dead looks like an API contract violation regarding
> rewriteheap.c.
Looking a bit more at that before the end of the day, I think that the
suggestion of touching HeapTupleSatisfiesVacuumHorizon() and setting
some hint bits would be the correct thing to do. One case that matters
is the "deleting subtransaction must have aborted" case. I am pretty
sure that we should also worry about the case where we check for
TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)), which
looks reachable, and set an extra hint bit there..
--
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, iderihatakeshi@gmail.com, zhong950419@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: <atceNofaGIE2dOFn@paquier.xyz>
References: <19760-8f9a0eba17bc8c92@postgresql.org> <41175da6-293f-4b8f-ad18-3636f3d8a2f6@gmail.com> <CAJTYsWXQgkqEpecZK9MCFVV+504oOdueuenRf+xTfNf9BcKE-g@mail.gmail.com> <CAGRkXqRMvz-ZzC88_eXsyJZRpPXhE4_Fo6ueYdm5tpH+CHc6EQ@mail.gmail.com> <5fff280b-96c4-497f-bbfc-0af95b9844b3@gmail.com> <CAGRkXqSo9vZ=7mw_X0tjH1-Wwdz8nWu9xpdX1x8hVM8tCazKAA@mail.gmail.com> <949ad7b3-2b0e-40dc-b6ac-e84da432149b@gmail.com> <atcbPTfcO9rihmbD@paquier.xyz> <atceNofaGIE2dOFn@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