[New-bugs-announce] [issue3512] Change fsync to use fullfsync on platforms (like OS X) that have/need it

Ian Charnas report at bugs.python.org
Thu Aug 7 06:07:41 CEST 2008

New submission from Ian Charnas <ian.charnas at gmail.com>:

fsync on OSX does not actually flush the file to disk as is desired. 
This is a problem because application developers rely on fsync for file
integrity.  SQLite [1] and MySQL [2] and other major database systems
all use 'fullfsync' on OS X instead of fsync, because 'fullfsync'
provides the desired behavior.

Because the documented behavior of python's fsync function is to "force
write of file with filedescriptor to disk", I believe that on OS X the
fullfsync call should be used instead of fsync.

The supplied patch adds this functionality in a non-platform-specific
way.  It checks if there is a FULLFSYNC fcntl call available (using
"#ifdef F_FULLFSYNC", where F_FULLFSYNC is defined in sys/fcntl.h), and
if this symbol is defined then a fnctl(F_FULLFSYNC, fd, 0) is called
instead of fsync.

[1] SQLite uses fullfsync on all platforms that define it:

[2] MySQL uses fullfsync only on the darwin platform and only when
F_FULLFSYNC is defined as 51, which seems to be short-sighted in that
this symbol may change value in future versions of OS X.  To see this
code, download a mysql 5.x source snapshot and open up

components: Library (Lib)
files: fullfsync.patch
keywords: patch
messages: 70810
nosy: icharnas
severity: normal
status: open
title: Change fsync to use fullfsync on platforms (like OS X) that have/need it
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file11066/fullfsync.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list