Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti

Поиск
Список
Период
Сортировка
Искать

Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Sun, Oct 25, 2026 at 8:56 PM Michael Paquier  wrote:
> 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.

Uggh. I think that this is the right fix given that
rewrite_heap_tuple() is documented to rely on hint bits being set for
correctness, but it seems to me to be pretty questionable that we rely
on hint bits being set for correctness. It's not going to be obvious
to someone modifying HeapTupleSatisfiesVacuum() or
HeapTupleSatisfiesVacuumHorizon() that rewrite_heap_tuple() critically
depends on that, and even if we added a comment about that, somebody
reading that comment might justifiably complain about our decision to
create such a dependency.

-- 
Robert Haas
Databricks


Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti

От:
Michael Paquier <michael@paquier.xyz>
Дата:
Вложения:
On Wed, Oct 28, 2026 at 03:32:44PM -0400, Robert Haas wrote:
> Uggh. I think that this is the right fix given that
> rewrite_heap_tuple() is documented to rely on hint bits being set for
> correctness, but it seems to me to be pretty questionable that we rely
> on hint bits being set for correctness. It's not going to be obvious
> to someone modifying HeapTupleSatisfiesVacuum() or
> HeapTupleSatisfiesVacuumHorizon() that rewrite_heap_tuple() critically
> depends on that, and even if we added a comment about that, somebody
> reading that comment might justifiably complain about our decision to
> create such a dependency.

As far as I know this is implied since 7b78474da356.  So it's been
around for some time...  It's really hard to miss, as the other thread
has proved.
--
Michael

Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti

От:
Michael Paquier <michael@paquier.xyz>
Дата:
Вложения:
On Thu, Oct 29, 2026 at 05:11:26PM +0900, Michael Paquier wrote:
> As far as I know this is implied since 7b78474da356.  So it's been
> around for some time...  It's really hard to miss, as the other thread
> has proved.

I meant the opposite here, as of "It's really *easy* to miss, as the
other thread has proved".  Sorry for the confusion.  :)
--
Michael

Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti

От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Fri, Oct 30, 2026 at 8:34 PM Michael Paquier  wrote:
> I meant the opposite here, as of "It's really *easy* to miss, as the
> other thread has proved".  Sorry for the confusion.  :)

That makes more sense. Not that I'm volunteering you, or myself, but
maybe somebody should put some effort into redesigning this so that
there isn't so much action-at-a-distance.

-- 
Robert Haas
Databricks


FAQ