[Zodb-checkins] SVN: ZODB/branches/3.8/ Backported fix for bug #126007.

Christian Theune ct at gocept.com
Tue Aug 28 02:05:15 EDT 2007


Log message for revision 79304:
  Backported fix for bug #126007.
  
  

Changed:
  U   ZODB/branches/3.8/NEWS.txt
  U   ZODB/branches/3.8/src/ZODB/blob.py
  U   ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt

-=-
Modified: ZODB/branches/3.8/NEWS.txt
===================================================================
--- ZODB/branches/3.8/NEWS.txt	2007-08-28 05:48:04 UTC (rev 79303)
+++ ZODB/branches/3.8/NEWS.txt	2007-08-28 06:05:14 UTC (rev 79304)
@@ -79,6 +79,9 @@
 Blobs
 -----
 
+- (3.8b3) Fixed bug #126007: tpc_abort had untested code path that was
+  broken.
+
 - (3.8b1) Updated the Blob implementation in a number of ways.  Some
   of these are backward incompatible with 3.8a1:
 

Modified: ZODB/branches/3.8/src/ZODB/blob.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/blob.py	2007-08-28 05:48:04 UTC (rev 79303)
+++ ZODB/branches/3.8/src/ZODB/blob.py	2007-08-28 06:05:14 UTC (rev 79304)
@@ -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/branches/3.8/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt	2007-08-28 05:48:04 UTC (rev 79303)
+++ ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt	2007-08-28 06:05:14 UTC (rev 79304)
@@ -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