Re: Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after - Mailing list pgsql-committers

From Tom Lane
Subject Re: Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after
Date
Msg-id 24404.1266850439@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after  (Greg Stark <gsstark@mit.edu>)
List pgsql-committers
Greg Stark <gsstark@mit.edu> writes:
> On Mon, Feb 22, 2010 at 2:54 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I also think it should scan the todir not the fromdir, just on
>> general principles to avoid any possibility of race conditions.

> I had concluded that scanning the original directory was odd but
> better because it served to double-check that all the original files
> actually made it and also because if there were any unrelated files
> present there was no need to fsync them.

Well, just for the record: if that was actually intentional then both of
you erred seriously by not including a comment that explained that the
coding was intentional (and giving the reasoning).  Any reader of the
code would have assumed that it was a copy-and-paste error, as I did.

> But I agree it's odd and not
> very general for copydir if we decide to use it elsewhere other than
> create database.

Yeah, to me it seems more likely to cause problems down the road than
to catch anything.  If the system is missing directory entries during
ReadDir then we have problems far beyond what copydir can deal with.
The point of the fsync loop is just to force the copy results down to
the platter, not to cross-check that the source directory isn't
changing.  (And, what's more, I don't believe that the source directory
can't change during CREATE DATABASE.  Consider delayed cleanup of
deleted relations during checkpoints.)

            regards, tom lane

pgsql-committers by date:

Previous
From: heikki@postgresql.org (Heikki Linnakangas)
Date:
Subject: pgsql: Move documentation of all recovery.conf option to a new chapter.
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Adjust pg_fsync_writethrough so that it will set errno when