RE: [ZODB-Dev] Use of fsync in FileStorage
"Tim Peters" <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb.dirstorage,gmane.comp.web.zope.zodb |
|---|---|
| Organization | Zope Corp |
| Message-ID | <[email protected]> |
[Jeremy Hylton]
> FileStorage calls flush() on the file after the tpc_vote(), which at
> least gets the data out of the application buffers into the os. Then it
> calls sync() in tpc_finish() and truncate() in tpc_abort(). I've got no
> clear understanding of what these actually do in the face of power
> failures.
Well, for one thing, the index file is written after the fsync() call, so a
power outage between could leave the .index file not matching the .fs file.
I think the code tries to check for that when opening a FileStorage, though,
and rebuilds the index file from scratch if the last transaction isn't
reflected in the index file it reads up.
The index file write doesn't do fsync() at all, which may be a real (but
never reported) problem on bouncing Windows systems (only _commit()
convinces Windows to write anything to disk:
f = open('temp.dat', 'wb')
import os
size = 0
data = 'x' * 100000
while 1:
f.write(data)
f.flush()
size += len(data)
print size, os.path.getsize('temp.dat')
On WinXP Pro just now, that printed
100000 0
200000 0
...
37100000 0
37200000 37100000
37300000 37100000
...
51800000 37100000
51900000 51800000
52000000 51800000
...
Stick in an os.fsync() call too, and the sizes always match.).
> I don't believe this is a critical issue.
It is if it happens <wink>.
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click