[Checkins] SVN: zc.zodbdgc/branches/dev/src/zc/zodbdgc/ Fixed 2 bugs:
Jim Fulton
jim at zope.com
Wed May 13 12:41:01 EDT 2009
Log message for revision 99893:
Fixed 2 bugs:
- Non-garbage objects could be lost due to a bug in saving references
to objects not known to be good.
- Invalid file names were egnerated using a flavor of base64 encoding
that uses '/'s.
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-13 15:02:13 UTC (rev 99892)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test 2009-05-13 16:41:01 UTC (rev 99893)
@@ -59,11 +59,16 @@
>>> conn1.root.x = C()
>>> conn2.root.x = C()
>>> conn3.root.x = C()
+ >>> conn1.root.i = C()
+ >>> conn1.root.j = C()
+ >>> conn1.root.lots = [C({'x': C()}) for i in range(1100)]
>>> transaction.commit()
>>> conn2.root.y = C()
>>> conn3.root.x = C()
+ >>> conn1.root.j.i = conn1.root.i
>>> transaction.commit()
>>> conn3.root.z = C()
+ >>> del conn1.root.i
>>> transaction.commit()
>>> conn1.root.x.y = conn2.root.y
@@ -92,7 +97,7 @@
>>> from ZODB.utils import u64, p64
>>> print u64(conn1.root.a._p_oid), u64(conn1.root.b._p_oid)
- 2 3
+ 2204 2205
>>> print u64(conn2.root.x._p_oid), u64(conn3.root.x._p_oid)
1 2
>>> del conn1.root.a
@@ -131,7 +136,7 @@
The number of objecs in the databases now:
>>> len(conn1._storage), len(conn2._storage), len(conn3._storage)
- (4, 5, 4)
+ (2206, 5, 4)
>>> for d in db.databases.values():
... d.pack()
@@ -139,7 +144,7 @@
Packing doesn't change it:
>>> len(conn1._storage), len(conn2._storage), len(conn3._storage)
- (4, 5, 4)
+ (2206, 5, 4)
>>> _ = conn1._storage.load(p64(2))
>>> _ = conn1._storage.load(p64(3))
@@ -162,8 +167,8 @@
>>> for name, oid in sorted(bad.iterator()):
... print name, u64(oid)
- db1 2
- db1 3
+ db1 2204
+ db1 2205
db2 1
db3 1
db3 2
@@ -177,7 +182,7 @@
haven't packed yet.
>>> len(conn1._storage), len(conn2._storage), len(conn3._storage)
- (4, 5, 4)
+ (2206, 5, 4)
>>> now += 1
@@ -185,7 +190,7 @@
... d.pack()
>>> len(conn1._storage), len(conn2._storage), len(conn3._storage)
- (2, 4, 2)
+ (2204, 4, 2)
>>> import ZODB.POSException
>>> for name, oid in bad.iterator():
@@ -273,7 +278,7 @@
... d.pack()
>>> len(conn1._storage), len(conn2._storage), len(conn3._storage)
- (2, 4, 2)
+ (2204, 4, 2)
>>> _ = [d.close() for d in db.databases.values()]
Modified: zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py
===================================================================
--- zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py 2009-05-13 15:02:13 UTC (rev 99892)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py 2009-05-13 16:41:01 UTC (rev 99893)
@@ -14,6 +14,7 @@
from ZODB.utils import u64, z64, p64
import BTrees.IIBTree
+import base64
import cPickle
import cStringIO
import logging
@@ -83,11 +84,11 @@
if not data:
continue
refs = tuple(ref for ref in getrefs(data, name)
- if (not good.has(*ref)) and not bad.has(*ref))
+ if not good.has(*ref))
if not refs:
continue # leaves are common
f = open(os.path.join(baddir, name,
- oid.encode('base64').strip()),
+ base64.urlsafe_b64encode(oid)),
'ab')
marshal.dump(refs, f)
f.close()
@@ -119,7 +120,7 @@
def bad_to_good(baddir, bad, good, name, oid):
bad.remove(name, oid)
- path = os.path.join(baddir, name, oid.encode('base64').strip())
+ path = os.path.join(baddir, name, base64.urlsafe_b64encode(oid))
if not os.path.exists(path):
return
More information about the Checkins
mailing list