Re: index corruption on composite primary key indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, "Ng, Stan" <sng(at)automotive(dot)com>, Mikael Krantz <mk(at)zigamorph(dot)se>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: index corruption on composite primary key indexes
Date: 2010-12-16 15:34:26
Message-ID: 21459.1292513666@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message H.Merijn Brand 2010-12-16 16:48:03 Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]
Previous Message Heikki Linnakangas 2010-12-16 14:57:53 Re: index corruption on composite primary key indexes