SVN: ZODB/trunk/src/ZEO/cache.py Don't update the cache lastTid until we've invalidated a value (rather

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 114602:
  Don't update the cache lastTid until we've invalidated a value (rather
  than before).  It's possible that process shutdown after updating
  lastTid but before invalidating the current record could explain some
  problems we've seen on restarts. (I can't think of a sane way to test
  this scenario.)
  

Changed:
  U   ZODB/trunk/src/ZEO/cache.py

-=-
Modified: ZODB/trunk/src/ZEO/cache.py
===================================================================
--- ZODB/trunk/src/ZEO/cache.py	2010-07-11 14:37:59 UTC (rev 114601)
+++ ZODB/trunk/src/ZEO/cache.py	2010-07-11 15:17:00 UTC (rev 114602)
@@ -437,10 +437,14 @@
     # recent tid.
     @locked
     def setLastTid(self, tid):
+        if (not tid) or (tid == z64):
+            return
         if (self.tid is not None) and (tid <= self.tid) and self:
+            if tid == self.tid:
+                return                  # Be a little forgiving
             raise ValueError("new last tid (%s) must be greater than "
-                             "previous one (%s)" % (u64(tid),
-                                                    u64(self.tid)))
+                             "previous one (%s)"
+                             % (u64(tid), u64(self.tid)))
         assert isinstance(tid, str) and len(tid) == 8, tid
         self.tid = tid
         self.f.seek(len(magic))
@@ -649,20 +653,11 @@
 
     @locked
     def invalidate(self, oid, tid, server_invalidation=True):
-        if tid is not None:
-            if tid > self.tid:
-                self.setLastTid(tid)
-            elif tid < self.tid:
-                if server_invalidation:
-                    raise ValueError("invalidation tid (%s) must not be less"
-                                     " than previous one (%s)" %
-                                     (u64(tid), u64(self.tid)))
-
         ofs = self.current.get(oid)
         if ofs is None:
             # 0x10 == invalidate (miss)
             self._trace(0x10, oid, tid)
-            return
+            return self.setLastTid(tid)
 
         self.f.seek(ofs)
         read = self.f.read
@@ -685,6 +680,8 @@
             # 0x1C = invalidate (hit, saving non-current)
             self._trace(0x1C, oid, tid)
 
+        return self.setLastTid(tid)
+
     ##
     # Generates (oid, serial) oairs for all objects in the
     # cache.  This generator is used by cache verification.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.