[Zodb-checkins] SVN: ZODB/branches/3.10/src/ Fixed a bug in ZEO client cache simulation that caused invalidations

Jim Fulton jim at zope.com
Tue Oct 26 17:29:13 EDT 2010


Log message for revision 117937:
  Fixed a bug in ZEO client cache simulation that caused invalidations
  to be misshandled, causing incorrect statistics and errors.
  

Changed:
  U   ZODB/branches/3.10/src/CHANGES.txt
  U   ZODB/branches/3.10/src/ZEO/scripts/cache_simul.py
  U   ZODB/branches/3.10/src/ZEO/tests/test_cache.py

-=-
Modified: ZODB/branches/3.10/src/CHANGES.txt
===================================================================
--- ZODB/branches/3.10/src/CHANGES.txt	2010-10-26 21:25:05 UTC (rev 117936)
+++ ZODB/branches/3.10/src/CHANGES.txt	2010-10-26 21:29:13 UTC (rev 117937)
@@ -25,6 +25,9 @@
   don't send invalidations. There's no reason to send them when an
   external garbage collector is used.
 
+- ZEO client cache simulation misshandled invalidations
+  causing incorrect statistics and errors.
+
 3.10.0 (2010-10-08)
 ===================
 

Modified: ZODB/branches/3.10/src/ZEO/scripts/cache_simul.py
===================================================================
--- ZODB/branches/3.10/src/ZEO/scripts/cache_simul.py	2010-10-26 21:25:05 UTC (rev 117936)
+++ ZODB/branches/3.10/src/ZEO/scripts/cache_simul.py	2010-10-26 21:29:13 UTC (rev 117937)
@@ -252,6 +252,8 @@
     nreports = 0
 
     def report(self):
+        if not hasattr(self, 'ts1'):
+            return
         self.nreports += 1
         args = (ctime(self.ts0)[4:-8],
                 duration(self.ts1 - self.ts0),
@@ -417,6 +419,9 @@
             # about this oid.
             self._remove_noncurrent_revisions(oid)
 
+        if oid in self.evicted:
+            del self.evicted[oid]
+
         cur_tid = self.current.get(oid)
         if cur_tid is None:
             # We don't have current data, so nothing more to do.

Modified: ZODB/branches/3.10/src/ZEO/tests/test_cache.py
===================================================================
--- ZODB/branches/3.10/src/ZEO/tests/test_cache.py	2010-10-26 21:25:05 UTC (rev 117936)
+++ ZODB/branches/3.10/src/ZEO/tests/test_cache.py	2010-10-26 21:29:13 UTC (rev 117937)
@@ -1028,6 +1028,36 @@
 
 """
 
+def cache_simul_properly_handles_load_miss_after_eviction_and_inval():
+    r"""
+
+Set up evicted and then invalidated oid
+
+    >>> os.environ["ZEO_CACHE_TRACE"] = 'yes'
+    >>> cache = ZEO.cache.ClientCache('cache', 1<<21)
+    >>> cache.store(p64(1), p64(1), None, 'x')
+    >>> for i in range(10):
+    ...     cache.store(p64(2+i), p64(1), None, 'x'*(1<<19)) # Evict 1
+    >>> cache.store(p64(1), p64(1), None, 'x')
+    >>> cache.invalidate(p64(1), p64(2))
+    >>> cache.load(p64(1))
+    >>> cache.close()
+
+Now try to do simulation:
+
+    >>> import ZEO.scripts.cache_simul
+    >>> ZEO.scripts.cache_simul.main('-s 1 cache.trace'.split())
+    ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
+    CircularCacheSimulation, cache size 1,048,576 bytes
+      START TIME   DUR.   LOADS    HITS INVALS WRITES HITRATE  EVICTS   INUSE
+          ...         0       1       0      1     12    0.0%      10    50.0
+    --------------------------------------------------------------------------
+          ...         0       1       0      1     12    0.0%      10    50.0
+
+    >>> del os.environ["ZEO_CACHE_TRACE"]
+
+    """
+
 def invalidations_with_current_tid_dont_wreck_cache():
     """
     >>> cache = ZEO.cache.ClientCache('cache', 1000)



More information about the Zodb-checkins mailing list