[Zope-dev] DB.close() needs to be called

Barry A. Warsaw barry@zope.com
Wed, 13 Nov 2002 09:10:38 -0500


>>>>> "TD" == Toby Dickenson <tdickenson@geminidataloggers.com> writes:

    >> This is a bad thing for the Berkeley storages because their
    >> .close() must get called or you'll end up with corrupt
    >> databases or worse <wink>.

    TD> How much of that paragraph is covered by the wink?

The "or worse" part.  If you've enable autopacking and you don't
cleanly close the storage, you won't exit the process because the
autopack thread won't get stopped and joined.  We could make the
autopack thread a daemon process, but it makes me nervous to do that
in the general case, because if you exit while autopack is running,
you could corrupt your database.  Hmm, I guess we could make it a
daemon process and yet still cleanly stop it on a close()...

    TD> Even before my recent changes, there are plenty of other ways
    TD> that Zope can open the storage, run a transaction, then hit an
    TD> error before properly starting up which means it fails to
    TD> close the database correctly.

    TD> Would this be bad?

It wouldn't be good, but remember that we run BerkeleyDB in
auto-recovery mode, so it means that the next time you open the
database, it will run recovery (you can also run recovery manually).
However, depending on your checkpointing policy, and the size of
committed data since your last checkpoint, recovery could end up
taking a long time.

Sure, any number of bad things can happen at any time, and defense
against that is one of the benefits of using BerkeleyDB underneath.
But under normal operations, we definitely want to exit cleanly.

    >> So here's a patch to z2.py to fix this.  I won't check this in
    >> because it looks a little ugly to me and I'm not sure what the
    >> right fix is,

    TD> That is exactly what I was planning to commit.

Cool. :)

    TD> Before making that change, I need to remove a couple other
    TD> calls to db.close() to prevent it being called twice on the
    TD> same db.

Ok.

    >> but we definitely need to fix this before Zope 2.6.1 is
    >> released.

    TD> 2.6.1? This change has only been on the trunk, not the 2.6
    TD> maintenance branch.

You're right.  I was running from the trunk.

Thanks,
-Barry