pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Ng, Stan <sng@automotive.com>
Cc: Mikael Krantz <mk@zigamorph.se>
Cc: Craig Ringer <craig@postnewspapers.com.au>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: index corruption on composite primary key indexes
Date: Thu, 16 Dec 2010 10:34:26 -0500
Message-ID: <21459.1292513666@sss.pgh.pa.us> (raw)
In-Reply-To: <4D0A28F1.3060502@enterprisedb.com>
References: <6B0DF81DDD9F654C932FB34C8D7ACE627E1760@mail-001.corp.automotive.com>
	<4D076758.8060605@postnewspapers.com.au>
	<6B0DF81DDD9F654C932FB34C8D7ACE627E1788@mail-001.corp.automotive.com>
	<AANLkTimHLhK5Pt-52fDnc5c8fJ1D9G37=H9-YigTgvwU@mail.gmail.com>
	<6B0DF81DDD9F654C932FB34C8D7ACE627E1888@mail-001.corp.automotive.com>
	<1292510876-sup-5298@alvh.no-ip.org>
	<4D0A28F1.3060502@enterprisedb.com>

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



view thread (10+ messages)

Message-ID: <21459.1292513666@sss.pgh.pa.us>
Permalink:  ../21459.1292513666@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21459.1292513666@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, heikki.linnakangas@enterprisedb.com, alvherre@commandprompt.com, sng@automotive.com, mk@zigamorph.se, craig@postnewspapers.com.au
  Subject: Re: index corruption on composite primary key indexes
  In-Reply-To: <21459.1292513666@sss.pgh.pa.us>
  References: <6B0DF81DDD9F654C932FB34C8D7ACE627E1760@mail-001.corp.automotive.com> <4D076758.8060605@postnewspapers.com.au> <6B0DF81DDD9F654C932FB34C8D7ACE627E1788@mail-001.corp.automotive.com> <AANLkTimHLhK5Pt-52fDnc5c8fJ1D9G37=H9-YigTgvwU@mail.gmail.com> <6B0DF81DDD9F654C932FB34C8D7ACE627E1888@mail-001.corp.automotive.com> <1292510876-sup-5298@alvh.no-ip.org> <4D0A28F1.3060502@enterprisedb.com> <21459.1292513666@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox