[ZODB-Dev] Use of fsync in ZODB

Marius Gedminas mgedmin at b4net.lt
Fri Jul 23 14:46:51 EDT 2004


I've been reading http://zope.org/Wikis/ZODB/FileStorageBackup (a
wonderful resource, thanks Tim!).  Among other things, it says:

   There's one exception to the rule that bytes in a FileStorage are
   never overwritten. When a new transaction is committed to a
   FileStorage, a special status byte is first written to record that a
   transaction record append has started. When the append is complete,
   this status byte (near the start of the new transaction record) is
   overwritten with a value indicating that the commit completed
   successfully. If, for example, the computer crashes before the append
   is complete, the next time the FileStorage is opened the status byte
   still has its initial "append started but didn't complete" value, and
   the FileStorage is then truncated, to remove the incomplete append.

After reading this paragraph I assumed that ZODB would call os.fsync
before overwriting the transaction status byte (and call os.fsync again
after overwriting it).  This turns out not to be the case -- in ZODB
3.2.2 (bundled with Zope 2.7.1) os.fsync is only called once, *after*
overwriting the transaction status byte, if I understood the code

Doesn't this mean that if the system suddenly crashes in the middle of
os.fsync, the Data.fs on disk will contain an incomplete transaction,
but the transaction status byte would claim that the transaction is
complete.  Wouldn't that be bad?

Just wondering,
Marius Gedminas
Eagleson's Law:
        Any code of your own that you haven't looked at for six or more
        months, might as well have been written by someone else.  (Eagleson
        is an optimist, the real number is more like three weeks.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20040723/73755138/attachment.bin

More information about the ZODB-Dev mailing list