[Zope-Checkins] CVS: ZODB3/ZODB/tests - PackableStorage.py:1.20.6.3 TransactionalUndoStorage.py:1.32.6.2

Tim Peters tim.one at comcast.net
Fri Jan 16 14:17:52 EST 2004


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv25285/ZODB/tests

Modified Files:
      Tag: Zope-2_7-branch
	PackableStorage.py TransactionalUndoStorage.py 
Log Message:
Backport "redundant pack" fix from the HEAD:  if you try to pack to a time
earlier than a .fs was previously packed to, the attempt shouldn't do
anything (except raise an exception).  It was trying to pack to the
earlier time anyway, but pack's reachability traversal can't work
correctly then due to the "missing" revisions in the gap between the
pack times, and the packed .fs could lose live data as a result.


=== ZODB3/ZODB/tests/PackableStorage.py 1.20.6.2 => 1.20.6.3 ===
--- ZODB3/ZODB/tests/PackableStorage.py:1.20.6.2	Mon Sep 15 17:26:57 2003
+++ ZODB3/ZODB/tests/PackableStorage.py	Fri Jan 16 14:17:51 2004
@@ -33,7 +33,8 @@
 from ZODB.referencesf import referencesf
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import snooze
-from ZODB.POSException import ConflictError
+from ZODB.POSException import ConflictError, StorageError
+from ZODB.PersistentMapping import PersistentMapping
 
 ZERO = '\0'*8
 
@@ -434,6 +435,50 @@
 
     def checkPackNowWhileWriting(self):
         self._PackWhileWriting(pack_now=1)
+
+    def checkRedundantPack(self):
+        # It is an error to perform a pack with a packtime earlier
+        # than a previous packtime.  The storage can't do a full
+        # traversal as of the packtime, because the previous pack may
+        # have removed revisions necessary for a full traversal.
+
+        # It should be simple to test that a storage error is raised,
+        # but this test case goes to the trouble of constructing a
+        # scenario that would lose data if the earlier packtime was
+        # honored.
+
+        self._initroot()
+
+        db = DB(self._storage)
+        conn = db.open()
+        root = conn.root()
+
+        root["d"] = d = PersistentMapping()
+        get_transaction().commit()
+        snooze()
+
+        obj = d["obj"] = C()
+        obj.value = 1
+        get_transaction().commit()
+        snooze()
+        packt1 = time.time()
+        lost_oid = obj._p_oid
+
+        obj = d["anotherobj"] = C()
+        obj.value = 2
+        get_transaction().commit()
+        snooze()
+        packt2 = time.time()
+
+        db.pack(packt2)
+        # BDBStorage allows the second pack, but doesn't lose data.
+        try:
+            db.pack(packt1)
+        except StorageError:
+            pass
+        # This object would be removed by the second pack, even though
+        # it is reachable.
+        self._storage.load(lost_oid, "")
 
     def checkPackUndoLog(self):
         self._initroot()


=== ZODB3/ZODB/tests/TransactionalUndoStorage.py 1.32.6.1 => 1.32.6.2 ===
--- ZODB3/ZODB/tests/TransactionalUndoStorage.py:1.32.6.1	Mon Sep 15 17:26:57 2003
+++ ZODB3/ZODB/tests/TransactionalUndoStorage.py	Fri Jan 16 14:17:51 2004
@@ -590,8 +590,8 @@
 
         pack_times = []
         def set_pack_time():
-            snooze()
             pack_times.append(time.time())
+            snooze()
 
         root["key0"] = MinPO(0)
         root["key1"] = MinPO(1)




More information about the Zope-Checkins mailing list