• Tim Peters's avatar
    Bugfix for pack(). Approximately forever, we've seen extremely rare · 95d715fc
    Tim Peters authored
    failures in the ZEO FileStorage pack-while-writing tests, where they die
    with
        CorruptedError: ... transaction with checkpoint flag set
    
    By coincidence, the same kind of death during pack() was reported on
    zodb-dev today(!).  The new checkPackLotsWhileWriting test provokes this
    on my box reliably (failed each time it was run).
    
    The problem appears to be that pack's idea of where a FileStorage
    ends was obtained merely by seeking to the end of the file.  But if
    a transaction is in progress, there can be an extra "not really there
    yet" transaction at the end of the file, and when either buildPackIndex()
    or findReachableFromFuture() bumped into a such a thing, the CorruptedError
    above got raised.  This is always rare, and was exceedingly rare before
    because only one pack per test was tried.  The new test tries packing
    repeatedly while a thread keeps hammering the database, so is much more
    likely to provoke the problem.
    
    The fix amounts to passing FileStorage._pos to the pack code, telling
    the latter directly where the legit transactions in the file end.
    95d715fc
FileStorage.py 68.4 KB