pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti
Date: Mon, 26 Oct 2026 00:55:35 +0000
Message-ID: <E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org> (raw)

Set HEAP_XMAX_INVALID for tuples updated by aborted subtransaction

HeapTupleSatisfiesVacuumHorizon() did not set HEAP_XMAX_INVALID on a
tuple inserted, then updated by a subtransaction that rolled back.
rewriteheap.c relies on this hint to tell if such tuples should be
treated as updated and would drop them, causing rewrites to lose some
tuples.

HeapTupleSatisfiesVacuumHorizon() is updated to set the hint
HEAP_XMAX_INVALID, so as heap AM is able to redirect such a tuple to its
correct route, and does not lose it.

This issue impacted both CLUSTER (down to v14) and REPACK [USING] (down
to v19).

Reported-by: Alperen Keles <alpkeles99@gmail.com>
Author: Shihao Zhong <zhong950419@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reported-by: Zhijie Hou <houzhijie22@gmail.com>
Reported-by: Takeshi Ideriha <iderihatakeshi@gmail.com>
Reported-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/19760-8f9a0eba17bc8c92@postgresql.org
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5df84b355ab78cfc3e8c10d37a80d627a53ed365

Modified Files
--------------
src/backend/access/heap/heapam_visibility.c |  2 ++
src/test/regress/expected/cluster.out       | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/cluster.sql            | 19 +++++++++++++++++++
3 files changed, 49 insertions(+)



view thread (11+ messages)  latest in thread

Message-ID: <E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org>
Permalink:  ../E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti
  In-Reply-To: <E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org>
  References: <E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org>

* 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