pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti
Date: 2026-10-26 00:55:35
Message-ID: E1xL8zv-00000000ljq-3fgR@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)gmail(dot)com>
Author: Shihao Zhong <zhong950419(at)gmail(dot)com>
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reported-by: Zhijie Hou <houzhijie22(at)gmail(dot)com>
Reported-by: Takeshi Ideriha <iderihatakeshi(at)gmail(dot)com>
Reported-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)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(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Richard Guo 2026-10-26 01:07:06 pgsql: Look through wrapper paths when collecting enforced clause seria
Previous Message Daniel Gustafsson 2026-10-25 23:30:35 pgsql: Fix tab completion for concurrent matview refresh