Re: initdb and fsync - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: initdb and fsync
Date
Msg-id 1339606397.23449.13.camel@jdavis
Whole thread Raw
In response to Re: initdb and fsync  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: initdb and fsync  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
On Wed, 2012-06-13 at 13:53 +0300, Peter Eisentraut wrote:
> The --help output for the -N option was copy-and-pasted wrongly.
>
> The message issued when using -N is also a bit content-free.  Maybe
> something like
>
> "Running in nosync mode.  The data directory might become corrupt if the
> operating system crashes.\n"

Thank you, fixed.

> Which leads to the question, how does one get out of this state?  Is
> running sync(1) enough?  Is starting the postgres server enough?

sync(1) calls sync(2), and the man page says:

"According to the standard specification  (e.g.,  POSIX.1-2001),  sync()
schedules the writes, but may return before the actual writing is done.
However, since version 1.3.20 Linux does actually  wait.   (This  still
does not guarantee data integrity: modern disks have large caches.)"

So it looks like sync is enough if you are on linux *and* you have any
unprotected write cache disabled.

I don't think starting the postgres server is enough.

Before, I think we were safe because we could assume that the OS would
flush the buffers before you had time to store any important data. But
now, that window can be much larger.

> There are no updates to the initdb man page included in your patch,
> which would be a suitable place to discuss this briefly.

Thank you, I added that.

Regards,
    Jeff Davis

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Mark JSON error detail messages for translation.
Next
From: Tom Lane
Date:
Subject: Re: [COMMITTERS] pgsql: Mark JSON error detail messages for translation.