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

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Sreekanth Palluru <sree4pg(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:01:15
Message-ID: CAB7nPqQxHoyTT=2jcXQzVOOFxqL=q4xU2w-pNS+Bf-HZ+mTERg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Sreekanth Palluru 2016-12-09 01:28:16 Re: Would like to below scenario is possible for getting page/block corruption
Previous Message Sreekanth Palluru 2016-12-09 00:46:07 Would like to below scenario is possible for getting page/block corruption

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2016-12-09 01:07:01 Re: Looking for an online mentor
Previous Message Metare Solve 2016-12-09 00:47:56 Re: Looking for an online mentor