Re: Is pg_control file crashsafe?

From: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
Subject: Re: Is pg_control file crashsafe?
Date: 2016-05-02 21:56:04
Message-ID: 5727CCF4.8070603@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01.05.2016 0:55, Bruce Momjian wrote:
> On Thu, Apr 28, 2016 at 09:58:00PM +0000, Alex Ignatov wrote:
>> Hello everyone!
>> We have some issue with truncated pg_control file on Windows after power
>> failure.
>> My questions is :
>> 1) Is pg_control protected from say , power crash or partial write?
>> 2) How PG update pg_control? By writing in it or writing in some temp file and
>> after that rename it to pg_control to be atomic?
> We write pg_controldata in one write() OS call:
>
> if (write(fd, buffer, PG_CONTROL_SIZE) != PG_CONTROL_SIZE)
>
>> 3) Can PG have multiple pg_control copy to be more fault tolerant?
>>
>> PS During some experiments we found that at present time there is no any method
>> to do crash recovery with "restored" version of pg_control (based on some
>> manipulations with pg_resetxlog ).
>> Only by using pg_resetxlog and setting it parameters to values taken from wal
>> file (pg_xlogdump)we can at least start PG and saw that PG state is at the
>> moment of last check point. But we have no real confidence that PG is in
>> consistent state(also docs on pg_resetxlogs told us about it too)
> We have talked about improving the reliability of pg_control, but
> failures are so rare we have never done anything to improve it. I know
> Tatsuo has talked about making pg_control more reliable, so I am CC'ing
> him.
>
Oh! Good. Thank you!
It is rare but as we saw now it is our reality too. One of our customers
had this issue on previous week =)

I think that rename can help a little bit. At least on some FS it is
atomic operation.

--
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2016-05-02 21:59:07 Re: Naming of new tsvector functions
Previous Message Andres Freund 2016-05-02 21:48:18 Reviewing freeze map code