Re: Allow WAL information to recover corrupted pg_controldata

From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'Alvaro Herrera'" <alvherre(at)commandprompt(dot)com>, 'Cédric Villemain' <cedric(at)2ndquadrant(dot)com>, "'Pg Hackers'" <pgsql-hackers(at)postgresql(dot)org>, "'Robert Haas'" <robertmhaas(at)gmail(dot)com>
Subject: Re: Allow WAL information to recover corrupted pg_controldata
Date: 2012-06-21 05:15:49
Message-ID: 003201cd4f6c$ecafaa10$c60efe30$@kapila@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I think you're missing the point. There is no possible way to guarantee database
> consistency after applying pg_resetxlog, unless the database had been cleanly shut
> down beforehand. The reset will lose the xlog information that was needed to restore
> consistency. So arguing from examples that demonstrate this is rather pointless.
> Rather, the value of pg_resetxlog is to be able to start the database at all so that
> info can be extracted from it. What we are looking for is not perfection, because
> that's impossible, but just to not make a bad situation worse.

I got the point that we cannot reconstruct a consistent database where further operations can be allowed.

> The reason I'm concerned about selecting a next-LSN that's certainly beyond every LSN in the database is that not doing
> so could result in introducing further corruption, which would be entirely avoidable with more care in choosing the
> next-LSN.

The further corruption can only be possible when we replay some wrong WAL by selecting wrong LSN.
Do you mean to say that if next-LSN is selected from pages, it will be a better position for starting Replay.
On the otherhand if we don't have to replay the WAL and just take the dump, how it will matter what is next-LSN.

>> Pg_resetxlog -
>> It will generate the next-LSN point as 109 which when used for recovery will generate inconsistent database.
>> However if we would have relied on WAL, it would have got next-LSN as 107.

>Umm ... the entire point of pg_resetxlog is to throw away WAL. Not to
>rely on it.

Yes, that is right but the solution I have purposed in my first mail was not to reset it after getting consistent checkpoint and generating control file values from it.
However now I understand that the problem and solution definition should consider that some WAL files are missing.

> It's conceivable that there would be some use in a tool that searches
> the available WAL files for the latest checkpoint record and recreates a
> pg_control file pointing at that checkpoint, without zapping the WAL
> files. This would be much different in purpose and usage from
> pg_resetxlog, though.

I will collect all the requirements that can be done in this area from existing mails and
think more in it to generate concrete set of requirements that can be helpful to users to over come
such situations.

Requirements or suggestions from all are most welcome. It can help me to do some useful work for
PostgreSQL.

With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2012-06-21 07:01:01 Pruning the TODO list
Previous Message Greg Smith 2012-06-21 04:57:20 Re: Backport of fsync queue compaction