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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-committers@postgresql.org, Greg Stark <stark@postgresql.org>
Date: 2010-02-22T02:54:40Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> I just found a relatively big problem with one of your modifications on the 
> patch - you removed the 
> FreeDir(xldir);
> xldir = AllocateDir(fromdir);
> pair - unfortunately its crucial because otherwise the DIR does not get 
> rewound - that resulted in *no* files getting fsync()ed (otherwise the loop 
> above wouldn't have finished yet...).
> I think that was also causing the problems I pointed out in " Directory fsync 
> and other fun"...

Actually, that code had *multiple* problems including stat'ing the wrong
file entirely, not to mention that this last commit failed to even
compile.  I also think it should scan the todir not the fromdir, just on
general principles to avoid any possibility of race conditions.

			regards, tom lane