Re: Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <stark(at)postgresql(dot)org>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-committers(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after
Date: 2010-02-22 14:53:59
Message-ID: 24404.1266850439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> On Mon, Feb 22, 2010 at 2:54 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-02-22 15:26:15 pgsql: Adjust pg_fsync_writethrough so that it will set errno when
Previous Message Heikki Linnakangas 2010-02-22 11:47:30 pgsql: Move documentation of all recovery.conf option to a new chapter.

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2010-02-22 15:31:45 Re: Plans for 9.1, Grouping Sets, disabling multiqueries, contrib module for string, plpgpsm, preload dictionaries
Previous Message Robert Haas 2010-02-22 14:46:36 ALTER TABLE documentation