[Zodb-checkins] SVN: ZODB/trunk/ Fixed bug #126007.
Christian Theune
ct at gocept.com
Tue Aug 28 01:48:05 EDT 2007
Log message for revision 79303:
Fixed bug #126007.
Changed:
U ZODB/trunk/NEWS.txt
U ZODB/trunk/src/ZODB/blob.py
U ZODB/trunk/src/ZODB/tests/blob_transaction.txt
-=-
Modified: ZODB/trunk/NEWS.txt
===================================================================
--- ZODB/trunk/NEWS.txt 2007-08-28 00:58:22 UTC (rev 79302)
+++ ZODB/trunk/NEWS.txt 2007-08-28 05:48:04 UTC (rev 79303)
@@ -28,7 +28,8 @@
Blobs
-----
--
+- (3.9.0a1) Fixed bug #126007: tpc_abort had untested code path that was
+ broken.
BTrees
------
Modified: ZODB/trunk/src/ZODB/blob.py
===================================================================
--- ZODB/trunk/src/ZODB/blob.py 2007-08-28 00:58:22 UTC (rev 79302)
+++ ZODB/trunk/src/ZODB/blob.py 2007-08-28 05:48:04 UTC (rev 79303)
@@ -447,7 +447,7 @@
while self.dirty_oids:
oid, serial = self.dirty_oids.pop()
clean = self.fshelper.getBlobFilename(oid, serial)
- if os.exists(clean):
+ if os.path.exists(clean):
remove_committed(clean)
@non_overridable
Modified: ZODB/trunk/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/trunk/src/ZODB/tests/blob_transaction.txt 2007-08-28 00:58:22 UTC (rev 79302)
+++ ZODB/trunk/src/ZODB/tests/blob_transaction.txt 2007-08-28 05:48:04 UTC (rev 79303)
@@ -37,7 +37,7 @@
>>> root1['blob1'] = blob1
>>> 'blob1' in root1
True
-
+
Aborting a blob add leaves the blob unchanged:
>>> transaction.abort()
@@ -310,7 +310,37 @@
...
IOError: ...
+tpc_abort with dirty data
+-------------------------
+When `tpc_abort` is called during the first commit phase we need to be able to
+clean up dirty files:
+
+ >>> class DummyBaseStorage(object):
+ ... def tpc_abort(self):
+ ... pass
+ >>> base_storage = DummyBaseStorage()
+ >>> blob_dir2 = mkdtemp()
+ >>> blob_storage = BlobStorage(blob_dir2, base_storage)
+ >>> committed_blob_dir = os.path.join(blob_dir2, '0')
+ >>> committed_blob_file = os.path.join(committed_blob_dir, '0.blob')
+ >>> os.mkdir(committed_blob_dir)
+ >>> open(os.path.join(committed_blob_file), 'w').write('foo')
+ >>> os.path.exists(committed_blob_file)
+ True
+
+Now, telling the storage that Blob 0 and Blob 1 (both with serial 0) are dirty
+will: remove the committed file for Blob 0 and ignore the fact that Blob 1 is
+set to dirty but doesn't actually have an existing file:
+
+ >>> blob_storage.dirty_oids = [(0, 0), (1, 0)]
+ >>> blob_storage.tpc_abort()
+ >>> os.path.exists(committed_blob_file)
+ False
+
+
+Note: This is a counter measure against regression of bug #126007.
+
Teardown
--------
@@ -319,3 +349,6 @@
>>> tm1.abort()
>>> tm2.abort()
>>> database.close()
+ >>> import shutil
+ >>> shutil.rmtree(blob_dir)
+ >>> shutil.rmtree(blob_dir2)
More information about the Zodb-checkins
mailing list