pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: John Lister <john.lister-ps@kickstone.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Database corruption help
Date: Sat, 14 Feb 2009 10:26:11 +0200
Message-ID: <49968023.8030404@enterprisedb.com> (raw)
In-Reply-To: <3161.1234541940@sss.pgh.pa.us>
References: <507152DDF8AB4DF093BD01A8BEC7C659@squarepi.com>
	<17205.1234200693@sss.pgh.pa.us>
	<AB15E89CD7FB4EBD9D76CC5F8D8B3D4E@squarepi.com>
	<4990840C.4090900@kickstone.com>
	<20151.1234208044@sss.pgh.pa.us>
	<49908D72.7040904@kickstone.com>
	<25753.1234224090@sss.pgh.pa.us>
	<4991338B.704@kickstone.com>
	<4994906B.6090408@kickstone.com>
	<17204.1234474784@sss.pgh.pa.us>
	<4994987F.1030204@kickstone.com>
	<17764.1234476783@sss.pgh.pa.us>
	<4994A45B.4030707@kickstone.com>
	<49952D33.3000707@kickstone.com>
	<3161.1234541940@sss.pgh.pa.us>

Tom Lane wrote:
> Aside from the "how did this happen" puzzle, the real point of any
> investigation of course ought to be whether we can make heap_page_prune
> more robust.  At the very least it's undesirable to be leaving the page
> in a state where VACUUM FULL will decide it can't shrink.

I'm as puzzled as you are on how it happened.

The fundamental problem here is that we have HOT-updated tuples that are 
missing the root tuple. heap_prune_chain doesn't know how to remove the 
dead tuples from such chains, and neither does vacuum. What's worse is 
that there's no index pointer to the live tuple in the chain, and even 
VACUUM FULL doesn't fix that.

Could we modify heap_page_prune so that it detects such orphaned HOT 
tuples, and clears the HOT_UPDATED flag for them? That would at least 
let you recover. I'm pretty wary of trying to "fix" things after 
corruption in general since you can't be sure what's correct and what's 
not, but clearing the HOT_UPDATED flag seems safe and more likely to 
help than hurt. Clearing the flag would let the tuple become indexed 
again in a VACUUM FULL or REINDEX, so it would fix the inconsistency 
that otherwise a sequential scan can see the tuple but an index scan can 
not. It would also allow the next heap_page_prune operation to remove 
the remaining dead tuples in the chain.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



view thread (19+ messages)  latest in thread

Message-ID: <49968023.8030404@enterprisedb.com>
Permalink:  ../49968023.8030404@enterprisedb.com/
Also on:    postgresql.org/message-id/49968023.8030404@enterprisedb.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: heikki.linnakangas@enterprisedb.com, tgl@sss.pgh.pa.us, john.lister-ps@kickstone.com, pgsql-hackers@postgresql.org
  Subject: Re: Database corruption help
  In-Reply-To: <49968023.8030404@enterprisedb.com>

* 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