Re: Is pg_control file crashsafe?

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, 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-04 13:58:49
Message-ID: CAA4eK1+1B4yDr2aW-wCa9S2yBN0VYjW8awEHbpHexLom1rR4_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 4, 2016 at 4:02 PM, Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
wrote:

>
>
> On 03.05.2016 2:17, Tom Lane wrote:
>
>> Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru> writes:
>>
>>> I think that rename can help a little bit. At least on some FS it is
>>> atomic operation.
>>>
>>
>> Writing a single sector ought to be atomic too. I'm very skeptical that
>> it'll be an improvement to just move the risk from one filesystem
>> operation to another; especially not to one where there's not even a
>> terribly portable way to request fsync.
>>
>> regards, tom lane
>>
>>
>> pg_control is 8k long(i think it is legth of one page in default PG
> compile settings).
> I also think that 8k recording can be atomic. Even if recording of one
> sector is atomic nobody can say about what sector from 8k record of
> pg_control should be written first. It can be last sector or say sector
> number 10 from 16.

The actual data written is always sizeof(ControlFileData) which should be
less than one sector. I think it is only possible that we get a torn write
for pg_control, if while writing + fsyncing, the filesystem maps that data
to different sectors.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-05-04 14:02:34 Re: 9.5.2: "sql" as reserved word?
Previous Message Marc Mamin 2016-05-04 13:58:24 9.5.2: "sql" as reserved word?