[Zodb-checkins] CVS: StandaloneZODB/bsddb3Storage/bsddb3Storage - BerkeleyBase.py:1.13.2.1

Barry Warsaw barry@wooz.org
Wed, 28 Nov 2001 18:03:59 -0500


Update of /cvs-repository/StandaloneZODB/bsddb3Storage/bsddb3Storage
In directory cvs.zope.org:/tmp/cvs-serv5004

Modified Files:
      Tag: StandaloneZODB-1_0-branch
	BerkeleyBase.py 
Log Message:
Port a patch from the trunk:

    close(): Do two forced checkpoints just before closing the
    environment.  This guarantees that any subsequent recovery will be
    very fast unless the database was not shut down gracefully.


=== StandaloneZODB/bsddb3Storage/bsddb3Storage/BerkeleyBase.py 1.13 => 1.13.2.1 ===
         its environment.
         """
-        # BAW: the original implementation also deleted the _env attribute.
-        # Was this just to reclaim the garbage?
+        # As recommended by Keith Bostic @ Sleepycat, we need to do
+        # two checkpoints just before we close the environment.
+        # Otherwise, auto-recovery on environment opens can be
+        # extremely costly.  We want to do auto-recovery for ease of
+        # use, although they aren't strictly necessary if the database
+        # was shutdown gracefully.  The DB_FORCE flag is required for
+        # the second checkpoint, but we include it in both because it
+        # can't hurt and is more robust.
+	self._env.txn_checkpoint(0, 0, db.DB_FORCE)
+	self._env.txn_checkpoint(0, 0, db.DB_FORCE)
         self._env.close()
         self._closelog()