[Checkins] SVN: zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/ checkpoint

Jim Fulton jim at zope.com
Tue Nov 17 17:21:20 EST 2009


Log message for revision 105780:
  checkpoint
  

Changed:
  U   zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/__init__.py
  U   zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/tests.py

-=-
Modified: zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/__init__.py
===================================================================
--- zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/__init__.py	2009-11-17 22:19:24 UTC (rev 105779)
+++ zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/__init__.py	2009-11-17 22:21:19 UTC (rev 105780)
@@ -322,6 +322,7 @@
         if self.blob_dir:
             self._remove_empty_notlast_blob_directories(self.blob_dir)
 
+    @retry_on_deadlock
     def _pack1(self, pack_tid):
         # Pack one transaction. Get the next transaction we haven't yet
         # packed and stop if it is > pack_tid.

Modified: zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/tests.py
===================================================================
--- zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/tests.py	2009-11-17 22:19:24 UTC (rev 105779)
+++ zc.bsddbstorage/branches/dev/src/zc/bsddbstorage/tests.py	2009-11-17 22:21:19 UTC (rev 105780)
@@ -12,6 +12,9 @@
 #
 ##############################################################################
 from zope.testing import doctest
+import cPickle
+import cStringIO
+import time
 import unittest
 import zc.bsddbstorage
 import ZODB.tests.BasicStorage
@@ -52,6 +55,58 @@
     checkLoadBeforeUndo = __disabled
     checkWriteMethods = __disabled
 
+    # Dang it, we really need to factor the pack tests for gc or no gc
+    def checkPackAllRevisions(self):
+
+
+        def pdumps(obj):
+            s = cStringIO.StringIO()
+            p = cPickle.Pickler(s)
+            p.dump(obj)
+            p.dump(None)
+            return s.getvalue()
+
+        
+        self._initroot()
+        eq = self.assertEqual
+        raises = self.assertRaises
+        # Create a `persistent' object
+        obj = self._newobj()
+        oid = obj.getoid()
+        obj.value = 1
+        # Commit three different revisions
+        revid1 = self._dostoreNP(oid, data=pdumps(obj))
+        obj.value = 2
+        revid2 = self._dostoreNP(oid, revid=revid1, data=pdumps(obj))
+        obj.value = 3
+        revid3 = self._dostoreNP(oid, revid=revid2, data=pdumps(obj))
+        # Now make sure all three revisions can be extracted
+        data = self._storage.loadSerial(oid, revid1)
+        pobj = cPickle.loads(data)
+        eq(pobj.getoid(), oid)
+        eq(pobj.value, 1)
+        data = self._storage.loadSerial(oid, revid2)
+        pobj = cPickle.loads(data)
+        eq(pobj.getoid(), oid)
+        eq(pobj.value, 2)
+        data = self._storage.loadSerial(oid, revid3)
+        pobj = cPickle.loads(data)
+        eq(pobj.getoid(), oid)
+        eq(pobj.value, 3)
+        # Now pack all transactions; need to sleep a second to make
+        # sure that the pack time is greater than the last commit time.
+        now = packtime = time.time()
+        while packtime <= now:
+            packtime = time.time()
+        self._storage.pack(packtime)
+        # All revisions of the object should be gone, since there is no
+        # reference from the root object to this object.
+        raises(KeyError, self._storage.loadSerial, oid, revid1)
+        raises(KeyError, self._storage.loadSerial, oid, revid2)
+
+        # Commented because No GC:
+        # raises(KeyError, self._storage.loadSerial, oid, revid3)
+
     def open(self, **kwargs):
         self._storage = zc.bsddbstorage.BSDDBStorage(
             'storage', **kwargs)



More information about the checkins mailing list