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

Barry Warsaw barry@wooz.org
Wed, 28 Nov 2001 14:22:05 -0500


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

Modified Files:
	BerkeleyBase.py 
Log Message:
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.14 ===
         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()