[Zodb-checkins] SVN: ZODB/trunk/src/ Bug fixed:
Jim Fulton
jim at zope.com
Tue Sep 28 11:34:03 EDT 2010
Log message for revision 117007:
Bug fixed:
- When using multi-databases, cache-management operations on a
connection, cacheMinimize and cacheGC, weren't applied to
subconnections.
Changed:
U ZODB/trunk/src/CHANGES.txt
U ZODB/trunk/src/ZODB/Connection.py
U ZODB/trunk/src/ZODB/tests/testConnection.py
-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt 2010-09-28 14:49:30 UTC (rev 117006)
+++ ZODB/trunk/src/CHANGES.txt 2010-09-28 15:34:03 UTC (rev 117007)
@@ -39,6 +39,10 @@
there aren't any transactions. Now a string of 8 nulls (aka "z64")
is specified.
+- When using multi-databases, cache-management operations on a
+ connection, cacheMinimize and cacheGC, weren't applied to
+ subconnections.
+
- Setting _p_changed on a blob wo actually writing anything caused an
error. (https://bugs.launchpad.net/zodb/+bug/440234)
Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py 2010-09-28 14:49:30 UTC (rev 117006)
+++ ZODB/trunk/src/ZODB/Connection.py 2010-09-28 15:34:03 UTC (rev 117007)
@@ -259,13 +259,17 @@
return obj
def cacheMinimize(self):
- """Deactivate all unmodified objects in the cache."""
- self._cache.minimize()
+ """Deactivate all unmodified objects in the cache.
+ """
+ for connection in self.connections.itervalues():
+ connection._cache.minimize()
# TODO: we should test what happens when cacheGC is called mid-transaction.
def cacheGC(self):
- """Reduce cache size to target size."""
- self._cache.incrgc()
+ """Reduce cache size to target size.
+ """
+ for connection in self.connections.itervalues():
+ connection._cache.incrgc()
__onCloseCallbacks = None
def onCloseCallback(self, f):
Modified: ZODB/trunk/src/ZODB/tests/testConnection.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testConnection.py 2010-09-28 14:49:30 UTC (rev 117006)
+++ ZODB/trunk/src/ZODB/tests/testConnection.py 2010-09-28 15:34:03 UTC (rev 117007)
@@ -759,6 +759,72 @@
"""
+def cache_management_of_subconnections():
+ """Make that cache management works for subconnections.
+
+When we use multi-databases, we open a connection in one database and
+access connections to other databases through it. This test verifies
+thatcache management is applied to all of the connections.
+
+Set up a multi-database:
+
+ >>> db1 = ZODB.DB(None)
+ >>> db2 = ZODB.DB(None, databases=db1.databases, database_name='2',
+ ... cache_size=10)
+ >>> conn1 = db1.open()
+ >>> conn2 = conn1.get_connection('2')
+
+Populate it with some data, more than will fit in the cache:
+
+ >>> for i in range(100):
+ ... conn2.root()[i] = conn2.root().__class__()
+
+Upon commit, the cache is reduced to the cache size:
+
+ >>> transaction.commit()
+ >>> conn2._cache.cache_non_ghost_count
+ 10
+
+Fill it back up:
+
+ >>> for i in range(100):
+ ... _ = str(conn2.root()[i])
+ >>> conn2._cache.cache_non_ghost_count
+ 101
+
+Doing cache GC on the primary also does it on the secondary:
+
+ >>> conn1.cacheGC()
+ >>> conn2._cache.cache_non_ghost_count
+ 10
+
+Ditto for cache minimize:
+
+ >>> conn1.cacheMinimize()
+ >>> conn2._cache.cache_non_ghost_count
+ 0
+
+
+Fill it back up:
+
+ >>> for i in range(100):
+ ... _ = str(conn2.root()[i])
+ >>> conn2._cache.cache_non_ghost_count
+ 101
+
+GC is done on reopen:
+
+ >>> conn1.close()
+ >>> db1.open() is conn1
+ True
+ >>> conn2 is conn1.get_connection('2')
+ True
+
+ >>> conn2._cache.cache_non_ghost_count
+ 10
+
+ """
+
class C_invalidations_of_new_objects_work_after_savepoint(Persistent):
def __init__(self):
self.settings = 1
More information about the Zodb-checkins
mailing list