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 <[email protected]> Author: Shihao Zhong <[email protected]> Author: Michael Paquier <[email protected]> Reported-by: Zhijie Hou <[email protected]> Reported-by: Takeshi Ideriha <[email protected]> Reported-by: Ayush Tiwari <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 14 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/928c2eeed5291ddd68d5872ee03eac1cd4f7f387 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(+)
