[ZODB-Dev] Use of fsync in FileStorage

Toby Dickenson tdickenson at devmail.geminidataloggers.co.uk
Wed Jul 28 06:21:13 EDT 2004


On Tuesday 27 July 2004 05:39, Tim Peters wrote:
> [Shane Hathaway]
> > It concerns me that we rely on fsync to maintain the integrity of a
> > FileStorage.
> 
> I think we rely much more on FileStorage's simplicity ("append") than on
> fsync. 

That is certainly true. Barring disk fragmentation, a small FileStorage 
transaction is likely to get sent to the hardware in a single operation. This 
leaves a very small window for partially written transactions.

> os.fsync() may be a real help (and definitely is on Windows) in case of
> power outage, but I'm not sure a case has been made that it has any other
> good effect.  

Backup power fails, operating systems crash, and sometimes power has to be 
pulled in an emergency. These things are rare, but not impossible. At the 
moment there is no good way to know *for* *sure* that your last transaction 
(or last backup, or the index file) is good after one of these disasters has 
occured.

Thorough use of fsync is about disaster-preparedness.

> > We could make it optional for  
> > FileStorage to call fsync, since fsync in general hurts performance and
> > disk life by forcing head movement.

fsync never improves performance, but it doesnt always hurt. On a good raid 
controller with battery-backed write cache you shouldnt see any difference.

-- 
Toby Dickenson


More information about the ZODB-Dev mailing list