[Zodb-checkins] SVN: ZODB/branches/jim-3.8-connection/src/ZEO/ The cache gets cranky when it sees invalidations out of order. It

Jim Fulton jim at zope.com
Mon Jul 14 10:39:31 EDT 2008


Log message for revision 88351:
  The cache gets cranky when it sees invalidations out of order.  It
  takes out-of-order invalidations as an indication that something is
  wrong. When committing transactions, however, caches are invalidated
  by the committing thread, while server invalidations are applied by
  the ZEO I/O thread.  This can lead to later server invalidations being
  applied before the commit invalidation.  I added a flag to only
  complain about out-of-order server invalidations.
  

Changed:
  U   ZODB/branches/jim-3.8-connection/src/ZEO/ClientStorage.py
  U   ZODB/branches/jim-3.8-connection/src/ZEO/cache.py

-=-
Modified: ZODB/branches/jim-3.8-connection/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/branches/jim-3.8-connection/src/ZEO/ClientStorage.py	2008-07-14 14:20:39 UTC (rev 88350)
+++ ZODB/branches/jim-3.8-connection/src/ZEO/ClientStorage.py	2008-07-14 14:39:30 UTC (rev 88351)
@@ -1115,7 +1115,7 @@
             return
 
         for oid, version, data in self._tbuf:
-            self._cache.invalidate(oid, version, tid)
+            self._cache.invalidate(oid, version, tid, False)
             # If data is None, we just invalidate.
             if data is not None:
                 s = self._seriald[oid]

Modified: ZODB/branches/jim-3.8-connection/src/ZEO/cache.py
===================================================================
--- ZODB/branches/jim-3.8-connection/src/ZEO/cache.py	2008-07-14 14:20:39 UTC (rev 88350)
+++ ZODB/branches/jim-3.8-connection/src/ZEO/cache.py	2008-07-14 14:39:30 UTC (rev 88351)
@@ -607,20 +607,30 @@
     # data for `oid`, stop believing we have current data, and mark the
     # data we had as being valid only up to `tid`.  In all other cases, do
     # nothing.
-    # @param oid object id
-    # @param version name of version to invalidate.
-    # @param tid the id of the transaction that wrote a new revision of oid,
+    #
+    # Paramters:
+    #
+    # - oid object id
+    # - version name of version to invalidate.
+    # - tid the id of the transaction that wrote a new revision of oid,
     #        or None to forget all cached info about oid (version, current
     #        revision, and non-current revisions)
+    # - server_invalidation, a flag indicating whether the
+    #       invalidation has come from the server. It's possible, due
+    #       to threading issues, that when applying a local
+    #       invalidation after a store, that later invalidations from
+    #       the server may already have arrived.
+    
     @locked
-    def invalidate(self, oid, version, tid):
+    def invalidate(self, oid, version, tid, server_invalidation=True):
         if tid is not None:
             if tid > self.tid:
                 self.setLastTid(tid)
             elif tid < self.tid:
-                raise ValueError("invalidation tid (%s) must not be less than "
-                                 "previous one (%s)" % (u64(tid),
-                                                        u64(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:



More information about the Zodb-checkins mailing list