New wal_sync_method for Darwin? - Mailing list pgsql-hackers

From Chris Campbell
Subject New wal_sync_method for Darwin?
Date
Msg-id 7988ba02eb01d8532576baa979a52be4@bignerdranch.com
Whole thread Raw
In response to Re: Fwd: Apple Darwin disabled fsync?  ("Jim C. Nasby" <decibel@decibel.org>)
List pgsql-hackers
I think we should add a new wal_sync_method that will use Darwin's 
F_FULLFSYNC fcntl().
From <sys/fnctl.h>:

#define F_FULLFSYNC     51              /* fsync + ask the drive to 
flush to the media */

This fcntl() will basically perform an fsync() on the file, then flush 
the write cache of the disk.

I'll attempt to work up the patch. It should be trivial. Might need 
some help on the configure tests though (it should #include 
<sys/fcntl.h> and make sure F_FULLFSYNC is defined).

What's an appropriate name? It seems equivalent to 
"fsync_writethrough". I suggest "fsync_full", "fsync_flushdisk", or 
something. Is there a reason we're not indicating the supported 
platform in the name of the method? Would "fsync_darwinfull" be better? 
Let users know that it's only available for Darwin? Should we do the 
same thing with win32-specific methods?

I think both fsync() and F_FULLFSYNC should both be available as 
options on Darwin. Currently in the code, "fsync" and 
"fsync_writethrough" set sync_method to SYNC_METHOD_FSYNC, so there's 
no way to distinguish between them.

Unsure which one would be the best default. fsync() matches the 
semantics on other platforms. And conscientious users could specify the 
F_FULLFSYNC fcntl() method if they want to make sure it goes through 
the write cache.

Comments?

Thanks!

- Chris

pgsql-hackers by date:

Previous
From: falcon
Date:
Subject: Why not cache stable functions?
Next
From: "Magnus Hagander"
Date:
Subject: Kerberos patch in the queue