[Zodb-checkins] SVN: ZODB/branches/3.5/ LP #142667: Use new cache for _reader in _resetCache.

Tres Seaver tseaver at palladion.com
Thu Oct 9 22:11:26 EDT 2008


Log message for revision 91950:
  LP #142667:  Use new cache for _reader in _resetCache.

Changed:
  U   ZODB/branches/3.5/NEWS.txt
  U   ZODB/branches/3.5/src/ZODB/Connection.py
  U   ZODB/branches/3.5/src/ZODB/tests/testConnection.py

-=-
Modified: ZODB/branches/3.5/NEWS.txt
===================================================================
--- ZODB/branches/3.5/NEWS.txt	2008-10-10 00:43:13 UTC (rev 91949)
+++ ZODB/branches/3.5/NEWS.txt	2008-10-10 02:11:25 UTC (rev 91950)
@@ -40,7 +40,7 @@
 _fsBTree
 --------
 
-- (3.5.2g1) Suppressed warnings about signedness of characters when
+- (3.5.2b1) Suppressed warnings about signedness of characters when
   compiling under GCC 4.0.x.  See http://www.zope.org/Collectors/Zope/2027.
 
 PersistentMapping
@@ -70,6 +70,11 @@
 Connection
 ----------
 
+- (3.52b1) Reset ``_cache`` on a connection's ``_reader`` object when
+  resetting the cache, to prevent reads from the old cache object, e.g.
+  during Zope2's auto-refresh of products.
+  (https://bugs.launchpad.net/zodb/+bug/142667).
+
 - (3.5.2b1) An optimization for loading non-current data (MVCC) was
   inadvertently disabled in ``_setstate()``; this has been repaired.
 

Modified: ZODB/branches/3.5/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/3.5/src/ZODB/Connection.py	2008-10-10 00:43:13 UTC (rev 91949)
+++ ZODB/branches/3.5/src/ZODB/Connection.py	2008-10-10 02:11:25 UTC (rev 91950)
@@ -954,6 +954,8 @@
         self._invalidated.clear()
         cache_size = self._cache.cache_size
         self._cache = cache = PickleCache(self, cache_size)
+        if getattr(self, '_reader', None) is not None:
+            self._reader._cache = cache
 
     ##########################################################################
     # Python protocol

Modified: ZODB/branches/3.5/src/ZODB/tests/testConnection.py
===================================================================
--- ZODB/branches/3.5/src/ZODB/tests/testConnection.py	2008-10-10 00:43:13 UTC (rev 91949)
+++ ZODB/branches/3.5/src/ZODB/tests/testConnection.py	2008-10-10 02:11:25 UTC (rev 91950)
@@ -146,6 +146,14 @@
         self.datamgr.tpc_finish(self.transaction)
         self.assert_(obj._p_oid not in self.datamgr._storage._stored)
 
+    def check__resetCacheResetsReader(self):
+        # https://bugs.launchpad.net/zodb/+bug/142667
+        old_cache = self.datamgr._cache
+        self.datamgr._resetCache()
+        new_cache = self.datamgr._cache
+        self.failIf(new_cache is old_cache)
+        self.failUnless(self.datamgr._reader._cache is new_cache)
+
 class UserMethodTests(unittest.TestCase):
 
     # add isn't tested here, because there are a bunch of traditional



More information about the Zodb-checkins mailing list