Re: BUG #17197: Assert failed on inserting index tuples after VACUUM

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17197: Assert failed on inserting index tuples after VACUUM
Date: 2021-09-20 20:35:26
Message-ID: CAH2-Wz=37_B-QwOrm1huKF0Dce=7y8kjSq2QhMePLVxaqB+EZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Sep 20, 2021 at 1:01 PM PG Bug reporting form
<noreply(at)postgresql(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2021-09-20 21:03:23 Re: BUG #17197: Assert failed on inserting index tuples after VACUUM
Previous Message PG Bug reporting form 2021-09-20 19:00:02 BUG #17197: Assert failed on inserting index tuples after VACUUM