Re: Would like to below scenario is possible for getting page/block corruption

From: Sreekanth Palluru <sree4pg(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Would like to below scenario is possible for getting page/block corruption
Date: 2016-12-09 01:28:16
Message-ID: CAP+fnpi7i4N_oqR9MmiqXueZN=p45Mop+HQNHT3feaW+OS28yA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Michael,
Can I generalize that, if after step 4) page ( new page or old page) got
written disk from buffer and crash happens between step 4) and 5) we
always get
block corruption issues with Postgres which can only be recovered by
setting zero_damaged_pages if we just have pg_dump backups and we are OK
lose data in the affected blocks?

I am also looking at ways of reproducing the issue ? appreciate your advice
on it ?

On Fri, Dec 9, 2016 at 12:01 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

> On Fri, Dec 9, 2016 at 9:46 AM, Sreekanth Palluru <sree4pg(at)gmail(dot)com>
> wrote:
> > Hi ,
> > I am working on page corruption issue want to know if below scenario is
> > possible
> >
> > 1) Insert command from client , I understand heap_insert is called from
> > heampam.c
> > 2) Let us say table is full and relation is extended and added a new
> block
> > 3) Tuple is inserted into new page for the block
> RelationPutHeapTuple/hio.c
> > 4) Later WAL record is inserted through recptr = XLogInsert(RM_HEAP_ID,
> > info);
> > 5) Then backend update the PageHeader with WAL LSN details
> PageSetLSN(page,
> > recptr);
> >
> > If my server got crashed after step 4) is there a possibility that after
> > postgres database restart I get below error when I access the relation
> or
> > vacuum is run on this relation or taking backup through pg_dump ?
> > ERROR: invalid page header in block 204 of relation base/16413/16900 ?
>
> So the block is corrupted. You may want to move to another server.
>
> > or
> > Postgres can automatically recover the page without throwing any error ?
>
> At crash recovery, Postgres would redo things from a point where
> everything was consistent on disk. If this corrupted page made it to
> disk, there is not much that can be done except restoring from a
> backup. You could as well zero_damaged_pages to help here, but you
> would lose the data on this page, still you would be able to perform
> pg_dump and get back as much data as you can. At the same time,
> corruption can spread as well as if that's a hardware problem, so you
> are just seeing the beginning of a series of problems.
> --
> Michael
>

--
Regards
Sreekanth

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Michael Paquier 2016-12-09 01:44:23 Re: Would like to below scenario is possible for getting page/block corruption
Previous Message Michael Paquier 2016-12-09 01:01:15 Re: Would like to below scenario is possible for getting page/block corruption

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2016-12-09 01:44:23 Re: Would like to below scenario is possible for getting page/block corruption
Previous Message Adrian Klaver 2016-12-09 01:24:18 Re: Looking for an online mentor