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

Barry Warsaw barry@wooz.org
Tue, 22 Oct 2002 19:05:41 -0400


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

Modified Files:
      Tag: bdb-nolocks
	Full.py 
Log Message:
Many changes to get all but the pack() related tests to pass.
Although a pack implementation has started, it's not ready for prime
time (this will come next).  Added packmark, oidqueue, and prevrevids
tables.  The first two are to support pack, the last is to support
multiple transactionalUndos in a single ZODB transaction.

_do() -> _withtxn(), along with signature chagnes for the meth
argument (for consistency).

Added support for data_txn in iterator data records, for restore()
backpointers, although restore() is not yet implemented in this
storage.


=== ZODB3/bsddb3Storage/bsddb3Storage/Full.py 1.44.2.2 => 1.44.2.3 === (849/949 lines abridged)
--- ZODB3/bsddb3Storage/bsddb3Storage/Full.py:1.44.2.2	Mon Sep 23 23:41:30 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/Full.py	Tue Oct 22 19:05:40 2002
@@ -32,6 +32,7 @@
 from ZODB.referencesf import referencesf
 from ZODB.TimeStamp import TimeStamp
 from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial
+import zLOG
 import ThreadLock
 
 # BerkeleyBase.BerkeleyBase class provides some common functionality for both
@@ -123,6 +124,12 @@
         #     This is a list of all the version ids that have been created in
         #     the current uncommitted transaction.
         #
+        # prevrevids -- {oid -> tid}
+        #     This is a list of previous revision ids for objects which are
+        #     modified by transactionalUndo in the current uncommitted
+        #     transaction.  It's necessary to properly handle multiple
+        #     transactionalUndo()'s in a single ZODB transaction.
+        #
         # pending -- tid -> 'A' | 'C'
         #     This is an optional flag which says what to do when the database
         #     is recovering from a crash.  The flag is normally 'A' which
@@ -140,7 +147,7 @@
         # versions -- {vid -> version_string}
         #     Maps vids to version strings.
         #
-        # currentVersions -- {vid -> oid + tid}
+        # currentVersions -- {vid -> [oid + tid]}
         #     Maps vids to the revids of the objects modified in that version
         #     for all current versions (except the 0th version, which is the
         #     non-version).
@@ -195,20 +202,27 @@
         #     Maps transaction ids to the oids of the objects modified by the
         #     transaction.
         #
-        # refcounts -- {oid -> count}
-        #     Maps objects to their reference counts.
-        #
         # pickleRefcounts -- {oid+tid -> count}
         #     Maps an object revision to the reference count of that
         #     revision's pickle.  In the face of transactional undo, multiple
         #     revisions can point to a single pickle so that pickle can't be
         #     garbage collected until there are no revisions pointing to it.
         #
+        # packmark -- [oid]
+        #     Every object reachable from the root during a classic pack
+        #     operation will have its oid present in this table.
+        #
+        # oidqueue -- [oid]

[-=- -=- -=- 849 lines omitted -=- -=- -=-]

             oid, ignore = decrefoids.popitem()
             self._zapobject(oid, decrefoids, referencesf)
 
-    def pack(self, t, referencesf):
-        # XXX log pack starts and stops
-
+    def pack(self, t, zreferencesf):
+        # For all intents and purposes, referencesf here is always going to be
+        # the same as ZODB.referencesf.referencesf.  It's too much of a PITA
+        # to pass that around to the helper methods, so just assert they're
+        # the same.
+        assert zreferencesf == referencesf
+        zLOG.LOG('Full storage', zLOG.INFO, 'pack started')
         # A simple wrapper around the bulk of packing, but which acquires a
         # lock that prevents multiple packs from running at the same time.
         self._packlock.acquire()
         try:
-            self._dopack(t, referencesf)
+            self._withtxn(self._dopack, t)
         finally:
             self._packlock.release()
+        zLOG.LOG('Full storage', zLOG.INFO, 'pack done')
 
     #
     # GCable interface, for cyclic garbage collection (untested)
@@ -1593,8 +1653,8 @@
         """
         # Let IndexError percolate up
         oid = self._oids.pop()
-        pickle, version = self._storage._loadSerialEx(oid, self.tid)
-        return _Record(oid, self.tid, version, pickle)
+        data, version, lrevid = self._storage._loadSerialEx(oid, self.tid)
+        return _Record(oid, self.tid, version, data, lrevid)
 
 
 
@@ -1607,9 +1667,12 @@
     version = None
     # Data pickle
     data = None
+    # The pointer to the transaction containing the pickle data, if not None
+    data_txn = None
 
-    def __init__(self, oid, serial, version, data):
+    def __init__(self, oid, serial, version, data, data_txn):
         self.oid = oid
         self.serial = serial
         self.version = version
         self.data = data
+        self.data_txn = data_txn