[Zodb-checkins] CVS: Zope/lib/python/ZODB/tests - PackableStorage.py:1.13.6.3

Jeremy Hylton jeremy at zope.com
Fri Jan 16 12:23:44 EST 2004


Update of /cvs-repository/Zope/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv5411/lib/python/ZODB/tests

Modified Files:
      Tag: Zope-2_6-branch
	PackableStorage.py 
Log Message:
Fix for FileStorage redundant pack bug.

Backported from the trunk.


=== Zope/lib/python/ZODB/tests/PackableStorage.py 1.13.6.2 => 1.13.6.3 ===
--- Zope/lib/python/ZODB/tests/PackableStorage.py:1.13.6.2	Tue May 20 08:58:21 2003
+++ Zope/lib/python/ZODB/tests/PackableStorage.py	Fri Jan 16 12:23:43 2004
@@ -29,11 +29,12 @@
 import time
 
 from ZODB import DB
+from Persistence import PersistentMapping
 from Persistence import Persistent
 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
 
 ZERO = '\0'*8
 
@@ -422,6 +423,50 @@
                 pass
         iter.close()
 
+    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, "")
+
 class ClientThread(threading.Thread):
 
     def __init__(self, db):
@@ -435,3 +480,4 @@
                 get_transaction().commit()
             except ConflictError:
                 get_transaction().abort()
+




More information about the Zodb-checkins mailing list