Re: BUG #17197: Assert failed on inserting index tuples after VACUUM - Mailing list pgsql-bugs

From Peter Geoghegan
Subject Re: BUG #17197: Assert failed on inserting index tuples after VACUUM
Date
Msg-id CAH2-Wz=37_B-QwOrm1huKF0Dce=7y8kjSq2QhMePLVxaqB+EZQ@mail.gmail.com
Whole thread Raw
In response to BUG #17197: Assert failed on inserting index tuples after VACUUM  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17197: Assert failed on inserting index tuples after VACUUM
List pgsql-bugs
On Mon, Sep 20, 2021 at 1:01 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
> Reproduced on REL_14_STABLE and master.
> The first bad commit is 3c3b8a4b.

I committed both the patch that added the failing assertion (bugfix
commit 4228817449) and the commit that allowed VACUUM to truncate line
pointers (commit 3c3b8a4b, "the first bad commit"). So I am very much
involved with both sides of the assertion failure that you found.

I am tempted to say that I should simply remove the assertion that
fails. But I won't do that before understanding what's going on here.

This is the assertion in question:

        offnum = ItemPointerGetOffsetNumber(htid);
        priorXmax = InvalidTransactionId;   /* cannot check first XMIN */
        for (;;)
        {
            ItemId      lp;
            HeapTupleHeader htup;

            /* Some sanity checks */
            if (offnum < FirstOffsetNumber || offnum > maxoff)
            {
                Assert(false);
                break;
            }

Similar code from heap_prune_chain() does not have the assertion. In
fact it's almost identical. This "can't happen" assertion was my own
recent addition, that could have easily been left out of commit
4228817449.

If this is a TID that came from the index then I cannot see what
business VACUUM has with setting it LP_UNUSED (and then truncating it
away entirely) -- clearly VACUUM should have deleted it from the index
first. Is there any easy way for you to check where this offnum came
from?

-- 
Peter Geoghegan



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17197: Assert failed on inserting index tuples after VACUUM
Next
From: Peter Geoghegan
Date:
Subject: Re: BUG #17197: Assert failed on inserting index tuples after VACUUM