[Zodb-checkins] CVS: ZODB3/bsddb3Storage/bsddb3Storage - Full.py:1.44.2.1

Barry Warsaw barry@wooz.org
Thu, 19 Sep 2002 18:11:17 -0400


Update of /cvs-repository/ZODB3/bsddb3Storage/bsddb3Storage
In directory cvs.zope.org:/tmp/cvs-serv14944

Modified Files:
      Tag: bdb-nolocks
	Full.py 
Log Message:
Start of code cleanup for new no-locks implementation.  This isn't
complete or functional yet, but I wanted to checkpoint it.  Note the
big comment about the new table layouts.  Next push will be from
abortVersion() on down.


=== ZODB3/bsddb3Storage/bsddb3Storage/Full.py 1.44 => 1.44.2.1 === (625/725 lines abridged)
--- ZODB3/bsddb3Storage/bsddb3Storage/Full.py:1.44	Tue Sep  3 16:27:32 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/Full.py	Thu Sep 19 18:11:17 2002
@@ -13,9 +13,6 @@
 ##############################################################################
 
 """Berkeley storage with full undo and versioning support.
-
-See Minimal.py for an implementation of Berkeley storage that does not support
-undo or versioning.
 """
 
 __version__ = '$Revision$'.split()[-2:][0]
@@ -23,15 +20,11 @@
 import sys
 import struct
 import time
-
-from cPickle import loads, Pickler
-Pickler = Pickler()
-Pickler.fast = 1 # Don't use a memo
-fast_pickle_dumps = Pickler.dump
-del Pickler
+import cPickle as pickle
 
 # This uses the Dunn/Kuchling PyBSDDB v3 extension module available from
-# http://pybsddb.sourceforge.net
+# http://pybsddb.sourceforge.net.  It is compatible with release 3.4 of
+# PyBSDDB3.
 from bsddb3 import db
 
 from ZODB import POSException
@@ -78,8 +71,8 @@
     def __init__(self, name, env=None, prefix='zodb_', config=None):
         """Initialize the Full database.
 
-        name, env, and prefix are passed straight through to the BerkeleyBase
-        base class constructor.
+        name, env, prefix, and config are passed straight through to the
+        BerkeleyBase base class constructor.
         """
         self._packlock = ThreadLock.allocate_lock()
         BerkeleyBase.__init__(self, name, env, prefix, config)
@@ -87,42 +80,56 @@
     def _setupDBs(self):
         # Data Type Assumptions:
         #
-        # - object ids (oid) are 8-bytes
-        # - object revision ids (revid) are 8-bytes
-        # - transaction ids (tid) are 8-bytes
-        # - version ids (vid) are 8-bytes

[-=- -=- -=- 625 lines omitted -=- -=- -=-]

+                self._docheckpoint()
+                raise
+            else:
+                txn.commit()
+                self._docheckpoint()
+        finally:
+            self._lock_acquire()
 
     #
     # Do some things in a version
     #
 
+    # XXX Take it from here...
+
     def abortVersion(self, version, transaction):
         # Abort the version, but retain enough information to make the abort
         # undoable.
@@ -675,22 +728,20 @@
         finally:
             self._lock_release()
 
-    def __findcreatevid(self, version):
+    def _findcreatevid(self, version, txn):
         # Get the vid associated with a version string, or create one if there
-        # is no vid for the version.
-        #
-        # First we look for the version in the Berkeley table.  If not
-        # present, then we look in the commit log to see if a new version
-        # creation is pending.  If still missing, then create the new version
-        # and add it to the commit log.
+        # is no vid for the version.  If we're creating a new version entry,
+        # we need to update the pvids table in case the transaction current in
+        # progress gets aborted.
         vid = self._vids.get(version)
         if vid is None:
-            vid = self._commitlog.get_vid(version)
-        if vid is None:
-            self.__nextvid = self.__nextvid + 1
-            # Convert the int/long version ID into an 8-byte string
+            self.__nextvid += 1
+            # Convert the version id into an 8-byte string
             vid = p64(self.__nextvid)
-            self._commitlog.write_new_version(version, vid)
+            # Now update the vids/versions tables, along with the log table
+            self._vids.put(version, vid, txn=txn)
+            self._versions.put(vid, version, txn=txn)
+            self._pvids.put(vid, txn=txn)
         return vid
 
     def _log_object(self, oid, vid, nvrevid, data, oserial):