Re: initdb and fsync - Mailing list pgsql-hackers

From Robert Haas
Subject Re: initdb and fsync
Date
Msg-id CA+TgmoayOyfhwfZbcXZTpnfqFxjNzrQdwAeFEvhHV7caVr_p7g@mail.gmail.com
Whole thread Raw
In response to Re: initdb and fsync  (Noah Misch <noah@leadboat.com>)
Responses Re: initdb and fsync  (Noah Misch <noah@leadboat.com>)
Re: initdb and fsync  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
On Sat, Feb 4, 2012 at 8:18 PM, Noah Misch <noah@leadboat.com> wrote:
> On Sat, Feb 04, 2012 at 03:41:27PM -0800, Jeff Davis wrote:
>> On Sat, 2012-01-28 at 13:18 -0500, Tom Lane wrote:
>> > Yeah.  Personally I would be sad if initdb got noticeably slower, and
>> > I've never seen or heard of a failure that this would fix.
>>
>> I worked up a patch, and it looks like it does about 6 file fsync's and
>> a 7th for the PGDATA directory. That degrades the time from about 1.1s
>> to 1.4s on my workstation.
>
>> So, is it worth it? Should we make it an option that can be specified?
>
> If we add fsync calls to the initdb process, they should cover the entire data
> directory tree.  This patch syncs files that initdb.c writes, but we ought to
> also sync files that bootstrap-mode backends had written.  An optimization
> like the pg_flush_data() call in copy_file() may reduce the speed penalty.
>
> initdb should do these syncs by default and offer an option to disable them.

This may be a stupid question, by why is it initdb's job to fsync the
files the server creates, rather than the server's job?  Normally we
rely on the server to make its own writes persistent.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: proposal and patch : support INSERT INTO...RETURNING with partitioned table using rule
Next
From: Robert Haas
Date:
Subject: Re: [PATCH 01/16] Overhaul walsender wakeup handling