Re: index corruption on composite primary key indexes - Mailing list pgsql-bugs

From Tom Lane
Subject Re: index corruption on composite primary key indexes
Date
Msg-id 21459.1292513666@sss.pgh.pa.us
Whole thread Raw
In response to Re: index corruption on composite primary key indexes  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-bugs
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> On 16.12.2010 16:50, Alvaro Herrera wrote:
>> All tuples need to have index pointers, even the dead ones.

> To be precise, tuples that are truly dead, ie. not visible to anyone
> anymore, don't need index pointers. They usually have index pointers
> anyway, because they were needed to find the tuples before they became
> dead. But if you abort a vacuum after it has scanned the indexes, you
> end up with dead heap tuples with no index pointers. Also, there's an
> optimization in b-tree that removes index pointers to dead tuples, when
> they are encountered during index scans.

Another way you can get to that state is failure while inserting the
index entries in the first place, eg one of the indexes reports a
uniqueness failure, whereupon we abort the inserting transaction.
Now the heap tuple is present but dead, and some of the table's indexes
may have entries for it while others don't.

The correct invariant is that (a) if an index entry exists, there must
be a heap tuple for it to point at, and (b) a live tuple must have all
the index entries it should have.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: index corruption on composite primary key indexes
Next
From: "Mariana Chigir"
Date:
Subject: Urgent inquiry