Commit 19a001f3 authored by Shane Hathaway's avatar Shane Hathaway

Fixed the _resetCache() bug. The garbage collection attributes weren't being

updated, which resulted in one whole cache being kept for no reason.
parent 716fc983
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Database connection support """Database connection support
$Id: Connection.py,v 1.80 2002/12/03 18:36:29 jeremy Exp $""" $Id: Connection.py,v 1.81 2003/01/14 15:20:21 shane Exp $"""
from cPickleCache import PickleCache from cPickleCache import PickleCache
from POSException import ConflictError, ReadConflictError from POSException import ConflictError, ReadConflictError
...@@ -217,7 +217,8 @@ class Connection(ExportImport.ExportImport): ...@@ -217,7 +217,8 @@ class Connection(ExportImport.ExportImport):
self._code_timestamp = global_code_timestamp self._code_timestamp = global_code_timestamp
self._invalidated.clear() self._invalidated.clear()
orig_cache = self._cache orig_cache = self._cache
self._cache = PickleCache(self, orig_cache.cache_size) self._cache = cache = PickleCache(self, orig_cache.cache_size)
self._incrgc = self.cacheGC = cache.incrgc
def abort(self, object, transaction): def abort(self, object, transaction):
"""Abort the object in the transaction. """Abort the object in the transaction.
......
...@@ -117,6 +117,21 @@ class ZODBTests(unittest.TestCase, ExportImportTests): ...@@ -117,6 +117,21 @@ class ZODBTests(unittest.TestCase, ExportImportTests):
self._db.abortVersion("version") self._db.abortVersion("version")
get_transaction().commit() get_transaction().commit()
def checkResetCache(self):
# The cache size after a reset should be 0 and the GC attributes
# ought to be linked to it rather than the old cache.
conn = self._db.open()
try:
conn.root()
self.assert_(len(conn._cache) > 0) # Precondition
conn._resetCache()
self.assertEqual(len(conn._cache), 0)
self.assert_(conn._incrgc == conn._cache.incrgc)
self.assert_(conn.cacheGC == conn._cache.incrgc)
finally:
conn.close()
def test_suite(): def test_suite():
return unittest.makeSuite(ZODBTests, 'check') return unittest.makeSuite(ZODBTests, 'check')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment