[Checkins] SVN: ZODB/branches/hannosch-lp533015-bytesizecache/src/ Apply the patch

Hanno Schlichting hannosch at hannosch.eu
Fri Mar 5 18:36:47 EST 2010


Log message for revision 109691:
  Apply the patch
  

Changed:
  U   ZODB/branches/hannosch-lp533015-bytesizecache/src/CHANGES.txt
  U   ZODB/branches/hannosch-lp533015-bytesizecache/src/ZODB/tests/testConnection.py
  U   ZODB/branches/hannosch-lp533015-bytesizecache/src/persistent/cPickleCache.c

-=-
Modified: ZODB/branches/hannosch-lp533015-bytesizecache/src/CHANGES.txt
===================================================================
--- ZODB/branches/hannosch-lp533015-bytesizecache/src/CHANGES.txt	2010-03-05 23:23:37 UTC (rev 109690)
+++ ZODB/branches/hannosch-lp533015-bytesizecache/src/CHANGES.txt	2010-03-05 23:36:47 UTC (rev 109691)
@@ -13,6 +13,13 @@
   help in situations where object ids are used as BTree keys and the
   sequential allocation of object ids leads to conflict errors.
 
+Bugs Fixed
+----------
+
+- The byte size limited pickle cache could overflow and effectively disable
+  the cache. (https://bugs.launchpad.net/zodb/+bug/533015)
+
+
 3.10.0a1 (2010-02-08)
 =====================
 

Modified: ZODB/branches/hannosch-lp533015-bytesizecache/src/ZODB/tests/testConnection.py
===================================================================
--- ZODB/branches/hannosch-lp533015-bytesizecache/src/ZODB/tests/testConnection.py	2010-03-05 23:23:37 UTC (rev 109690)
+++ ZODB/branches/hannosch-lp533015-bytesizecache/src/ZODB/tests/testConnection.py	2010-03-05 23:36:47 UTC (rev 109691)
@@ -685,11 +685,26 @@
         # 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, cache = self.obj, 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 <= 1000)
 
 
-
-
-
 # ---- stubs
 
 class StubObject(Persistent):

Modified: ZODB/branches/hannosch-lp533015-bytesizecache/src/persistent/cPickleCache.c
===================================================================
--- ZODB/branches/hannosch-lp533015-bytesizecache/src/persistent/cPickleCache.c	2010-03-05 23:23:37 UTC (rev 109690)
+++ ZODB/branches/hannosch-lp533015-bytesizecache/src/persistent/cPickleCache.c	2010-03-05 23:36:47 UTC (rev 109691)
@@ -667,7 +667,7 @@
 {
   PyObject *oid;
   cPersistentObject *v;
-  unsigned int new_size;
+  int new_size;
   if (!PyArg_ParseTuple(args, "OI:updateObjectSizeEstimation", &oid, &new_size))
     return NULL;
   /* Note: reference borrowed */



More information about the checkins mailing list