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_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0b565674945c2b08d131f2d821400ed11181ac37 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(+)
