Re: Incorrect assumption in heap_prepare_freeze_tuple

From: Andres Freund <andres(at)anarazel(dot)de>
To: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Incorrect assumption in heap_prepare_freeze_tuple
Date: 2020-10-03 19:03:05
Message-ID: 20201003190305.fbr6uhrw2rcuj5f3@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2020-10-03 19:57:03 +0530, Kuntal Ghosh wrote:
> You've also mentioned that HEAPTUPLE_DEAD case I'm referring to can
> only be hit for for tuples that are *newer* than OldestXmin but become
> DEAD (instead of RECENTLY_DEAD) because the inserting transaction
> aborted. But, I don't see that's the only case when
> HeapTupleSatisfiesVacuum returns HEAPTUPLE_DEAD. If
> HeapTupleSatisfiesVacuumHorizon returns HEAPTUPLE_RECENTLY_DEAD and if
> tuple xmax(dead_after) precedes OlestXmin, we set it as
> HEAPTUPLE_DEAD.
>
> res = HeapTupleSatisfiesVacuumHorizon(htup, buffer, &dead_after);
>
> if (res == HEAPTUPLE_RECENTLY_DEAD)
> {
> Assert(TransactionIdIsValid(dead_after));
>
> if (TransactionIdPrecedes(dead_after, OldestXmin))
> res = HEAPTUPLE_DEAD;
> }
> else
> Assert(!TransactionIdIsValid(dead_after));
>
> Am I missing something here?

To get to this point heap_page_prune() has to have been called for the
page. That removes all tuple [versions] that are DEAD. But not
RECENTLY_DEAD. But RECENTLY_DEAD can only happen for tuples that are
newere than OldestXmin. Thus the only tuples that the HTSV() we're
talking about can return DEAD for are ones that were RECENTLY_DEAD
in heap_page_prune().

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2020-10-03 20:13:28 Re: POC: contrib/unaccent as IMMUTABLE
Previous Message John Naylor 2020-10-03 17:31:51 Re: Add primary keys to system catalogs