Re: Data corruption zero a file - help!!

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Noel Faux <noel(dot)faux(at)med(dot)monash(dot)edu(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Data corruption zero a file - help!!
Date: 2006-03-09 19:43:36
Message-ID: 20060309194336.GA91732@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Mar 09, 2006 at 03:57:46PM +1100, Noel Faux wrote:
> Given that this seems problem has occurred a number of times for a
> number I've written a small step by step procedure to address this
> issue. Is there any other comments you which to add. I was thinking
> that this should be added to the FAQ / troubleshooting in the docs.
>
> How to repair corrupted data due to "ERROR: invalid page header in block
> X of relation "Y":

In pgsql-novice Christopher Goodfellow mentioned the zero_damaged_pages
option that I had forgotten about. If you don't care about examining
the bad pages then you could set this option in a session and execute
a statement that hits every page in the file (Tom Lane mentioned
VACUUM and SELECT COUNT(*)). Here's the example I posted in reply:

test=# select count(*) from foo;
ERROR: invalid page header in block 10 of relation "foo"
test=# set zero_damaged_pages to on;
SET
test=# select count(*) from foo;
WARNING: invalid page header in block 10 of relation "foo"; zeroing out page
WARNING: invalid page header in block 20 of relation "foo"; zeroing out page
WARNING: invalid page header in block 30 of relation "foo"; zeroing out page
count
-------
9445
(1 row)

test=# set zero_damaged_pages to off;
SET

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Pawley 2006-03-09 19:50:38 JDBC
Previous Message Michael Fuhr 2006-03-09 19:26:10 Re: NULL TIMESTAM problem