[Checkins] SVN: zc.zodbdgc/branches/dev/src/zc/zodbdgc/ Handle references to databases outside the configuration in the check

Jim Fulton jim at zope.com
Wed May 27 13:34:32 EDT 2009


Log message for revision 100484:
  Handle references to databases outside the configuration in the check
  script.
  
  Note that, so far, I'm not handling outside references in the gc
  script. These broken references will have to be cleaned up before
  doing gc.
  

Changed:
  U   zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test
  U   zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py

-=-
Modified: zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test
===================================================================
--- zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test	2009-05-27 17:16:58 UTC (rev 100483)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test	2009-05-27 17:34:32 UTC (rev 100484)
@@ -371,6 +371,24 @@
 missing link from db1 to db3 because the referencing object was
 incorrectly removed as garbage.
 
+
+If we see references to databases we haven't heard of, we just report them:
+
+    >>> open('config2', 'w').write("""
+    ... <zodb db1>
+    ...     <filestorage>
+    ...         path 1.fs-2
+    ...         blob-dir 1.blobs-2
+    ...     </filestorage>
+    ... </zodb>
+    ... """)
+
+    >>> zc.zodbdgc.check_command(['config2'])
+    !!! db1 2206 db1 0
+    POSKeyError: 'No blob file'
+    !!! db2 2 db1 2
+    KeyError: 'db2'
+
 .. cleanup
 
     >>> logging.getLogger().setLevel(old_level)

Modified: zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py
===================================================================
--- zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py	2009-05-27 17:16:58 UTC (rev 100483)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py	2009-05-27 17:34:32 UTC (rev 100484)
@@ -227,7 +227,10 @@
 
     def has(self, name, oid):
         ioid1, ioid2 = divmod(u64(oid), 2147483648L)
-        data = self[name].get(ioid1)
+        try:
+            data = self[name].get(ioid1)
+        except KeyError:
+            return False
         return bool(data and (int(ioid2) in data))
 
     def iterator(self, name=None):
@@ -278,10 +281,10 @@
     seen = oidset(databases)
     while roots:
         name, oid = roots.pop()
-        if not seen.insert(name, oid):
-            continue
 
         try:
+            if not seen.insert(name, oid):
+                continue
             p, tid = storages[name].load(oid, '')
             if ZODB.blob.is_blob_record(p):
                 storages[name].loadBlob(oid, tid)



More information about the Checkins mailing list