Commit eb444b8b authored by Jim Fulton's avatar Jim Fulton

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

parent a0567579
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
Change History Change History
================ ================
3.9.0b2 (2009-05-??)
====================
Bugs Fixed
----------
- Deleted records weren't removed when packing file storages.
3.9.0b1 (2009-05-04) 3.9.0b1 (2009-05-04)
==================== ====================
......
...@@ -1193,7 +1193,7 @@ class ServerManagingClientStorage(ClientStorage): ...@@ -1193,7 +1193,7 @@ class ServerManagingClientStorage(ClientStorage):
def tpc_abort(self, id): def tpc_abort(self, id):
self.rpc.call('tpc_abort', 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: if shared:
server_blob_dir = blob_dir server_blob_dir = blob_dir
else: else:
...@@ -1206,9 +1206,10 @@ class ServerManagingClientStorage(ClientStorage): ...@@ -1206,9 +1206,10 @@ class ServerManagingClientStorage(ClientStorage):
blob-dir %s blob-dir %s
<filestorage> <filestorage>
path %s path %s
%s
</filestorage> </filestorage>
</blobstorage> </blobstorage>
""" % (server_blob_dir, name+'.fs'), """ % (server_blob_dir, name+'.fs', extrafsoptions),
port=port, port=port,
) )
os.remove(config) os.remove(config)
...@@ -1260,7 +1261,8 @@ def test_suite(): ...@@ -1260,7 +1261,8 @@ def test_suite():
) )
zeo.addTest(PackableStorage.IExternalGC_suite( zeo.addTest(PackableStorage.IExternalGC_suite(
lambda : lambda :
ServerManagingClientStorageForIExternalGCTest('data.fs', 'blobs') ServerManagingClientStorageForIExternalGCTest(
'data.fs', 'blobs', extrafsoptions='pack-gc false')
)) ))
for klass in quick_test_classes: for klass in quick_test_classes:
zeo.addTest(unittest.makeSuite(klass, "check")) zeo.addTest(unittest.makeSuite(klass, "check"))
......
...@@ -219,7 +219,11 @@ class GC(FileStorageFormatter): ...@@ -219,7 +219,11 @@ class GC(FileStorageFormatter):
while pos < end: while pos < end:
dh = self._read_data_header(pos) dh = self._read_data_header(pos)
self.checkData(th, tpos, dh, 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() pos += dh.recordlen()
tlen = self._read_num(pos) 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: ...@@ -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, '') >>> p0, s0 = storage.load(oid0, '')
>>> p1, s1 = storage.load(oid1, '') >>> 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 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 go through the database to do this, so we'll have to manage the
transaction ourselves. transaction ourselves.
...@@ -62,11 +74,11 @@ We can still get the data if we load before the time we deleted. ...@@ -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 If we pack, however, the old data will be removed and the data will be
gone: gone:
>>> import time
>>> db.pack(time.time()+1) >>> db.pack(time.time()+1)
>>> len(db.storage)
1
>>> time.sleep(.1)
>>> time.sleep(1)
>>> storage.load(oid0, '') # doctest: +ELLIPSIS >>> storage.load(oid0, '') # doctest: +ELLIPSIS
Traceback (most recent call last): Traceback (most recent call last):
......
...@@ -587,7 +587,8 @@ def test_suite(): ...@@ -587,7 +587,8 @@ def test_suite():
test_packing=True, test_packing=True,
)) ))
suite.addTest(PackableStorage.IExternalGC_suite( 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 return suite
if __name__=='__main__': 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