[Checkins] SVN: ZODB/trunk/src/ Bug Fixed: Deleted records weren't removed when packing file storages.

Jim Fulton jim at zope.com
Mon May 11 17:08:05 EDT 2009


Log message for revision 99856:
  Bug Fixed: Deleted records weren't removed when packing file storages.
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZEO/tests/testZEO.py
  U   ZODB/trunk/src/ZODB/FileStorage/fspack.py
  U   ZODB/trunk/src/ZODB/tests/IExternalGC.test
  U   ZODB/trunk/src/ZODB/tests/testFileStorage.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2009-05-11 18:49:48 UTC (rev 99855)
+++ ZODB/trunk/src/CHANGES.txt	2009-05-11 21:08:05 UTC (rev 99856)
@@ -2,6 +2,14 @@
  Change History
 ================
 
+3.9.0b2 (2009-05-??)
+====================
+
+Bugs Fixed
+----------
+
+- Deleted records weren't removed when packing file storages.
+
 3.9.0b1 (2009-05-04)
 ====================
 

Modified: ZODB/trunk/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/testZEO.py	2009-05-11 18:49:48 UTC (rev 99855)
+++ ZODB/trunk/src/ZEO/tests/testZEO.py	2009-05-11 21:08:05 UTC (rev 99856)
@@ -1193,7 +1193,7 @@
         def tpc_abort(self, id):
             self.rpc.call('tpc_abort', id)
 
-    def __init__(self, name, blob_dir, shared=False):
+    def __init__(self, name, blob_dir, shared=False, extrafsoptions=''):
         if shared:
             server_blob_dir = blob_dir
         else:
@@ -1206,9 +1206,10 @@
                 blob-dir %s
                 <filestorage>
                    path %s
+                   %s
                 </filestorage>
             </blobstorage>
-            """ % (server_blob_dir, name+'.fs'),
+            """ % (server_blob_dir, name+'.fs', extrafsoptions),
             port=port,
             )
         os.remove(config)
@@ -1260,7 +1261,8 @@
         )
     zeo.addTest(PackableStorage.IExternalGC_suite(
         lambda :
-        ServerManagingClientStorageForIExternalGCTest('data.fs', 'blobs')
+        ServerManagingClientStorageForIExternalGCTest(
+            'data.fs', 'blobs', extrafsoptions='pack-gc false')
         ))
     for klass in quick_test_classes:
         zeo.addTest(unittest.makeSuite(klass, "check"))

Modified: ZODB/trunk/src/ZODB/FileStorage/fspack.py
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/fspack.py	2009-05-11 18:49:48 UTC (rev 99855)
+++ ZODB/trunk/src/ZODB/FileStorage/fspack.py	2009-05-11 21:08:05 UTC (rev 99856)
@@ -219,7 +219,11 @@
             while pos < end:
                 dh = self._read_data_header(pos)
                 self.checkData(th, tpos, dh, pos)
-                self.oid2curpos[dh.oid] = pos
+                if dh.plen or dh.back:
+                    self.oid2curpos[dh.oid] = pos
+                else:
+                    if dh.oid in self.oid2curpos:
+                        del self.oid2curpos[dh.oid]
                 pos += dh.recordlen()
 
             tlen = self._read_num(pos)

Modified: ZODB/trunk/src/ZODB/tests/IExternalGC.test
===================================================================
--- ZODB/trunk/src/ZODB/tests/IExternalGC.test	2009-05-11 18:49:48 UTC (rev 99855)
+++ ZODB/trunk/src/ZODB/tests/IExternalGC.test	2009-05-11 21:08:05 UTC (rev 99856)
@@ -25,6 +25,18 @@
     >>> p0, s0 = storage.load(oid0, '')
     >>> p1, s1 = storage.load(oid1, '')
 
+The storage is configured not to gc on pack, so even if we pack, these
+objects won't go away:
+
+    >>> len(storage)
+    3
+    >>> import time
+    >>> db.pack(time.time()+1)
+    >>> len(storage)
+    3
+    >>> p0, s0 = storage.load(oid0, '')
+    >>> p1, s1 = storage.load(oid1, '')
+
 Now we'll use the new deleteObject API to delete the objects. We can't
 go through the database to do this, so we'll have to manage the
 transaction ourselves.
@@ -62,12 +74,12 @@
 If we pack, however, the old data will be removed and the data will be
 gone:
 
-    >>> import time
     >>> db.pack(time.time()+1)
+    >>> len(db.storage)
+    1
 
+    >>> time.sleep(.1)
 
->>> time.sleep(1)
-
     >>> storage.load(oid0, '') # doctest: +ELLIPSIS
     Traceback (most recent call last):
     ...

Modified: ZODB/trunk/src/ZODB/tests/testFileStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testFileStorage.py	2009-05-11 18:49:48 UTC (rev 99855)
+++ ZODB/trunk/src/ZODB/tests/testFileStorage.py	2009-05-11 21:08:05 UTC (rev 99856)
@@ -587,7 +587,8 @@
         test_packing=True,
         ))
     suite.addTest(PackableStorage.IExternalGC_suite(
-        lambda : ZODB.FileStorage.FileStorage('data.fs', blob_dir='blobs')))
+        lambda : ZODB.FileStorage.FileStorage(
+            'data.fs', blob_dir='blobs', pack_gc=False)))
     return suite
 
 if __name__=='__main__':



More information about the Checkins mailing list