[Zodb-checkins] CVS: ZODB/src/ZODB/FileStorage - FileStorage.py:1.5

Tim Peters tim.one at comcast.net
Thu Feb 26 13:05:23 EST 2004


Update of /cvs-repository/ZODB/src/ZODB/FileStorage
In directory cvs.zope.org:/tmp/cvs-serv29442/src/ZODB/FileStorage

Modified Files:
	FileStorage.py 
Log Message:
loadBefore():  This forgot to acquire the lock.  That's a clear bug.
However, fixing it so far *appears* to fix a bunch of shy FileStorage
pack[Now]WhileWriting test failures whose connection to loadBefore()
isn't obvious.  It's plausible that it's a real fix for those, just
not (yet) compelling.  It seems very likely to be a real fix for very
rare failures that have shown up only in ChrisM's overnight testrunner
reports (because those did have stuff related to loadBefore() in their
tracebacks).


=== ZODB/src/ZODB/FileStorage/FileStorage.py 1.4 => 1.5 ===
--- ZODB/src/ZODB/FileStorage/FileStorage.py:1.4	Tue Feb 17 20:13:00 2004
+++ ZODB/src/ZODB/FileStorage/FileStorage.py	Thu Feb 26 13:05:22 2004
@@ -589,35 +589,40 @@
             self._lock_release()
 
     def loadBefore(self, oid, tid):
-        pos = self._lookup_pos(oid)
-        end_tid = None
-        while True:
-            h = self._read_data_header(pos, oid)
-            if h.version:
-                # Just follow the pnv pointer to the previous
-                # non-version data.
-                if not h.pnv:
-                    # Object was created in version.  There is no
-                    # before data to find.
-                    return None
-                pos = h.pnv
-                # The end_tid for the non-version data is not affected
-                # by versioned data records.
-                continue
+        self._lock_acquire()
+        try:
+            pos = self._lookup_pos(oid)
+            end_tid = None
+            while True:
+                h = self._read_data_header(pos, oid)
+                if h.version:
+                    # Just follow the pnv pointer to the previous
+                    # non-version data.
+                    if not h.pnv:
+                        # Object was created in version.  There is no
+                        # before data to find.
+                        return None
+                    pos = h.pnv
+                    # The end_tid for the non-version data is not affected
+                    # by versioned data records.
+                    continue
+
+                if h.tid < tid:
+                    break
 
-            if h.tid < tid:
-                break
+                pos = h.prev
+                end_tid = h.tid
+                if not pos:
+                    return None
 
-            pos = h.prev
-            end_tid = h.tid
-            if not pos:
-                return None
+            if h.back:
+                data, _, _, _ = self._loadBack_impl(oid, h.back)
+                return data, h.tid, end_tid
+            else:
+                return self._file.read(h.plen), h.tid, end_tid
 
-        if h.back:
-            data, _, _, _ = self._loadBack_impl(oid, h.back)
-            return data, h.tid, end_tid
-        else:
-            return self._file.read(h.plen), h.tid, end_tid
+        finally:
+            self._lock_release()
 
     def modifiedInVersion(self, oid):
         self._lock_acquire()




More information about the Zodb-checkins mailing list