Commit 2943740a authored by Jim Fulton's avatar Jim Fulton

Bug Fixed: Deleted records weren't removed when packing file storages.

parent 4ea687c9
......@@ -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)
====================
......
......@@ -1193,7 +1193,7 @@ class ServerManagingClientStorage(ClientStorage):
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 @@ class ServerManagingClientStorage(ClientStorage):
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 @@ def test_suite():
)
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"))
......
......@@ -219,7 +219,11 @@ class GC(FileStorageFormatter):
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)
......
......@@ -25,6 +25,18 @@ At this point, object 0 and 1 is garbage, but it's still in the storage:
>>> 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,11 +74,11 @@ We can still get the data if we load before the time we deleted.
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):
......
......@@ -587,7 +587,8 @@ def test_suite():
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__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment