[Python-Dev] small PATCH to fix os.fsync on OS X

Scott Dial scott+python-dev at scottdial.com
Thu Aug 7 06:52:34 CEST 2008


Ian Charnas wrote:
> As noted by SQLite [1] and MySQL [2] developers, fsync on OS X does
> not actually flush a file to disk... instead OS X provides "fullfsync"
> which actually flushes the file descriptor to disk.  This simple patch
> modifies python's "fsync" to take advantage of fullfsync on platforms
> that support it:
> http://bugs.python.org/issue3512

I don't believe your patch is correct. My understanding is that fsync() 
on OS X does the exact same thing as it does on any other POSIX 
platform. On all platforms, fsync() does not guarantee that your data 
has made it to permanent storage. fcntl(fd, F_FULLSYNC) is an additional 
feature on OS X to force the OS X to wait for the underlying device's 
write buffers to have cleared. See the discussion on darwin-dev[1]:

"""
So in summary, I believe that the comments in the MySQL news posting
are slightly confused.  On MacOS X fsync() behaves the same as it does
on all Unices.  That's not good enough if you really care about data
integrity and so we also provide the F_FULLFSYNC fcntl.  As far as I
know, MacOS X is the only OS to provide this feature for apps that
need to truly guarantee their data is on disk.
"""

If you want this feature to be accessible in python, then I think you 
should modify the fcntl module to include F_FULLSYNC.

-Scott

[1] http://lists.apple.com/archives/darwin-dev/2005/Feb/msg00072.html

-- 
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu


More information about the Python-Dev mailing list