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

From: Greg Stark <stark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <stark(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after
Date: 2010-02-23 09:12:02
Message-ID: 407d949e1002230112o569eea1w97fd1aacc5a8bcec@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Tue, Feb 23, 2010 at 5:37 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-02-23 15:38:53 Re: [COMMITTERS] Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after
Previous Message Andres Freund 2010-02-23 07:43:21 Re: [COMMITTERS] Re: pgsql: Speed up CREATE DATABASE by deferring the fsyncs until after

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2010-02-23 09:37:10 Re: tie user processes to postmaster was:(Re: [HACKERS] scheduler in core)
Previous Message Stefan Kaltenbrunner 2010-02-23 09:00:57 SR/libpq - outbound interface/ipaddress binding