[Zodb-checkins] SVN: ZODB/trunk/src/ Forward ported r109789, r110123-110124 from 3.9 branch to trunk
Hanno Schlichting
hannosch at hannosch.eu
Tue Mar 23 18:53:25 EDT 2010
Log message for revision 110125:
Forward ported r109789, r110123-110124 from 3.9 branch to trunk
Changed:
U ZODB/trunk/src/CHANGES.txt
U ZODB/trunk/src/ZODB/tests/testConnection.py
U ZODB/trunk/src/persistent/cPickleCache.c
-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt 2010-03-23 22:48:36 UTC (rev 110124)
+++ ZODB/trunk/src/CHANGES.txt 2010-03-23 22:53:24 UTC (rev 110125)
@@ -8,6 +8,9 @@
Bugs Fixed
----------
+- Fixed bug in cPickleCache's byte size estimation logic.
+ (https://bugs.launchpad.net/zodb/+bug/533015)
+
- When using using a ClientStorage in a Storage server, there was a
threading bug that caused clients to get disconnected.
Modified: ZODB/trunk/src/ZODB/tests/testConnection.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testConnection.py 2010-03-23 22:48:36 UTC (rev 110124)
+++ ZODB/trunk/src/ZODB/tests/testConnection.py 2010-03-23 22:53:24 UTC (rev 110125)
@@ -685,11 +685,27 @@
# sanity check
self.assert_(cache.total_estimated_size >= 0)
+ def test_cache_garbage_collection_shrinking_object(self):
+ db = self.db
+ # activate size based cache garbage collection
+ db.setCacheSizeBytes(1000)
+ obj, conn, cache = self.obj, self.conn, self.conn._cache
+ # verify the change worked as expected
+ self.assertEqual(cache.cache_size_bytes, 1000)
+ # verify our entrance assumption is fullfilled
+ self.assert_(cache.total_estimated_size > 1)
+ # give the objects some size
+ obj.setValueWithSize(500)
+ transaction.savepoint()
+ self.assert_(cache.total_estimated_size > 500)
+ # make the object smaller
+ obj.setValueWithSize(100)
+ transaction.savepoint()
+ # make sure there was no overflow
+ self.assert_(cache.total_estimated_size != 0)
+ # the size is not larger than the allowed maximum
+ self.assert_(cache.total_estimated_size <= 1000)
-
-
-
-
# ---- stubs
class StubObject(Persistent):
Modified: ZODB/trunk/src/persistent/cPickleCache.c
===================================================================
--- ZODB/trunk/src/persistent/cPickleCache.c 2010-03-23 22:48:36 UTC (rev 110124)
+++ ZODB/trunk/src/persistent/cPickleCache.c 2010-03-23 22:53:24 UTC (rev 110125)
@@ -668,7 +668,8 @@
PyObject *oid;
cPersistentObject *v;
unsigned int new_size;
- if (!PyArg_ParseTuple(args, "OI:updateObjectSizeEstimation", &oid, &new_size))
+ if (!PyArg_ParseTuple(args, "OI:updateObjectSizeEstimation",
+ &oid, &new_size))
return NULL;
/* Note: reference borrowed */
v = (cPersistentObject *)PyDict_GetItem(self->data, oid);
@@ -680,8 +681,9 @@
if (v->ring.r_next)
{
self->total_estimated_size += _estimated_size_in_bytes(
- _estimated_size_in_24_bits(new_size) - v->estimated_size
- );
+ (int)(_estimated_size_in_24_bits(new_size))
+ - (int)(v->estimated_size)
+ );
/* we do this in "Connection" as we need it even when the
object is not in the cache (or not the ring)
*/
More information about the Zodb-checkins
mailing list