[Zodb-checkins] CVS: ZODB3/ZODB/FileStorage - FileStorage.py:1.1.2.12

Jeremy Hylton cvs-admin at zope.org
Thu Nov 20 12:26:51 EST 2003


Update of /cvs-repository/ZODB3/ZODB/FileStorage
In directory cvs.zope.org:/tmp/cvs-serv12641

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	FileStorage.py 
Log Message:
Fix several versions issues.

When returning non-version data via pnv, make sure the transaction id
returned is the current one.  It's possible for the cache to have
non-current data with the old txn id, so it's not safe to return it
for the current data.

loadSerial() was calling old, incorrect _loadBack() instead of
self._loadBack().

Add assertion about increasing tids in loadEx() and XXX comment about
worrisome test of serial instead of tid.


=== ZODB3/ZODB/FileStorage/FileStorage.py 1.1.2.11 => 1.1.2.12 ===
--- ZODB3/ZODB/FileStorage/FileStorage.py:1.1.2.11	Tue Nov 18 12:08:49 2003
+++ ZODB3/ZODB/FileStorage/FileStorage.py	Thu Nov 20 12:26:50 2003
@@ -542,9 +542,15 @@
             pos = self._lookup_pos(oid)
             h = self._read_data_header(pos, oid)
             if h.version and h.version != version:
-                # Skip this txn's record entirely.  Return data, serial, tid
-                # from non-version data.
-                return self._loadBackTxn(oid, h.pnv)
+                # Retrun data and serial from pnv (non-version data).
+
+                # If we return the old record's transaction id, then
+                # it will look to the cache like old data is current.
+                # The tid for the current data must always be greater
+                # than any non-current data.
+                data, serial, _, _ = self._loadBack_impl(oid, h.pnv)
+                th = self._read_txn_header(h.tloc)
+                return data, serial, th.tid
             if h.plen:
                 data = self._file.read(h.plen)
                 th = self._read_txn_header(h.tloc)
@@ -588,8 +594,7 @@
             if h.plen:
                 return self._file.read(h.plen)
             else:
-                # XXX Must be self._loadBack...
-                return _loadBack(self._file, oid, h.back)[0]
+                return self._loadBack_impl(oid, h.back)[0]
         finally:
             self._lock_release()
 
@@ -598,6 +603,7 @@
         end_tid = None
         while True:
             h = self._read_data_header(pos, oid)
+            # XXX abort version?
             if h.serial < tid and not h.version:
                 break
             pos = h.prev
@@ -609,6 +615,7 @@
             # _loadBack() will return the serialno and tid of the txn
             # pointed to, which is wrong.  Only use it for the data.
             th = self._read_txn_header(h.tloc)
+            assert th.tid < tid
             data = self._loadBack_impl(oid, h.back)[0]
             return data, h.serial, th.tid, end_tid
         else:




More information about the Zodb-checkins mailing list