Re: HOT chain validation in verify_heapam()

Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>

From: Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>, Aleksander Alekseev <aleksander@timescale.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2022-11-17T15:56:57Z
Lists: pgsql-hackers
On Wed, Nov 16, 2022 at 12:41 PM Himanshu Upadhyaya <
upadhyaya.himanshu@gmail.com> wrote:

>
>
>> > +             }
>> > +
>> > +             /* Loop over offsets and validate the data in the
>> predecessor array. */
>> > +             for (OffsetNumber currentoffnum = FirstOffsetNumber;
>> currentoffnum <= maxoff;
>> > +                      currentoffnum = OffsetNumberNext(currentoffnum))
>> > +             {
>> > +                     HeapTupleHeader pred_htup;
>> > +                     HeapTupleHeader curr_htup;
>> > +                     TransactionId pred_xmin;
>> > +                     TransactionId curr_xmin;
>> > +                     ItemId          pred_lp;
>> > +                     ItemId          curr_lp;
>> > +
>> > +                     ctx.offnum = predecessor[currentoffnum];
>> > +                     ctx.attnum = -1;
>> > +
>> > +                     if (ctx.offnum == 0)
>> > +                     {
>> > +                             /*
>> > +                              * Either the root of the chain or an
>> xmin-aborted tuple from
>> > +                              * an abandoned portion of the HOT chain.
>> > +                              */
>>
>> Hm - couldn't we check that the tuple could conceivably be at the root of
>> a
>> chain? I.e. isn't HEAP_HOT_UPDATED? Or alternatively has an aborted xmin?
>>
>>
>  I don't see a way to check if tuple is at the root of HOT chain because
> predecessor array will always be having either xmin from non-abandoned
> transaction or it will be zero. We can't differentiate root or tuple
> inserted via abandoned transaction.
>
> I was wrong here. I think this can be done and will be doing these changes
in my next patch.


-- 
Regards,
Himanshu Upadhyaya
EnterpriseDB: http://www.enterprisedb.com

Commits

  1. amcheck: Generalize one of the recently-added update chain checks.

  2. amcheck: Tighten up validation of redirect line pointers.

  3. amcheck: Fix verify_heapam for tuples where xmin or xmax is 0.

  4. amcheck: Fix a few bugs in new update chain validation.

  5. Fix new test case to work on (some?) big-endian architectures.

  6. Don't test HEAP_XMAX_INVALID when freezing xmax.