Re: [COMMITTERS] Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after
Greg Stark <stark@mit.edu>
From: Greg Stark <stark@mit.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Greg Stark <stark@postgresql.org>, Andres Freund <andres@anarazel.de>, pgsql-hackers@postgresql.org
Date: 2010-02-23T09:12:02Z
Lists: pgsql-hackers
On Tue, Feb 23, 2010 at 5:37 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > So the problem is that fsync_fname is trying to fsync a file it's opened > O_RDONLY. I don't know whether Windows is similarly picky, but we'll > soon find out. > Argh, now I feel silly. I had actually found that in my searches after the first batch of problems. But somehow i didn't connect that to the current problems. Sorry. There are other similarly confused OSes that don't allow fsync on read-only file descriptors: http://svn.haxx.se/dev/archive-2006-02/0488.shtml (I wonder if some of them are doing fsync wrong and only syncing changes written to this file descriptor and not any file descriptor for this file?) The plan I was thinking of was to pass a flag indicating if it's a directory to fsync_fname() and open it RD_ONLY if it's a directory and RDRW if it's a file. Then ignore any error returns (or at least EBADF and EINVAL) iff the flag indicating it was a directory was true. I don't like using configure tests for this because I fear someone could compile Postgres on a system with one set of behaviour and then switch to a different kernel version with a different set of behaviour. In the worst case it could be filesystem dependent whether you can open directories or whether they accept fsyncs. -- greg