This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Change fsync to use fullfsync on platforms (like OS X) that have/need it
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, icharnas
Priority: normal Keywords: patch

Created on 2008-08-07 04:07 by icharnas, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fullfsync.patch icharnas, 2008-08-07 04:07
Messages (5)
msg70810 - (view) Author: Ian Charnas (icharnas) Date: 2008-08-07 04:07
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:
http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/os_unix.c

[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
mysql-<version-number>/innobase/os/os0file.c
msg70811 - (view) Author: Ian Charnas (icharnas) Date: 2008-08-07 04:09
My patch is against trunk, but really this fix should be applied to all
versions that will have future releases.
msg70835 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-08-07 16:20
IMO it would be better not to confuse matters my having os.fsync() call
fullfsync(); it's better to add a separate os.fullfsync() call on
platforms that support it.  That way the application can choose.  I
suppose Apple had a reason for changing the behavior...
msg70839 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-08-07 16:53
Based on discussion in python-dev, I'm rejecting this patch.

Open a new one if you want to make F_FULLSYNC available.
msg70843 - (view) Author: Ian Charnas (icharnas) Date: 2008-08-07 17:38
Done.  See 3517
http://bugs.python.org/issue3517

On Thu, Aug 7, 2008 at 12:53 PM, Guido van Rossum
<report@bugs.python.org> wrote:
>
> Guido van Rossum <guido@python.org> added the comment:
>
> Based on discussion in python-dev, I'm rejecting this patch.
>
> Open a new one if you want to make F_FULLSYNC available.
>
> ----------
> resolution:  -> rejected
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3512>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47762
2008-08-07 17:38:12icharnassetmessages: + msg70843
2008-08-07 16:53:30gvanrossumsetstatus: open -> closed
resolution: rejected
messages: + msg70839
2008-08-07 16:20:31gvanrossumsetnosy: + gvanrossum
messages: + msg70835
2008-08-07 04:09:41icharnassetmessages: + msg70811
2008-08-07 04:07:39icharnascreate