[Zodb-checkins] SVN: ZODB/trunk/src/ Fixed a bug that caused savepoint rollback to not properly

Jim Fulton jim at zope.com
Mon Apr 26 16:34:58 EDT 2010


Log message for revision 111453:
  Fixed a bug that caused savepoint rollback to not properly
  set object state when objects implemented _p_invalidate methods
  that reloaded ther state (unghostifiable objects).
  
  https://bugs.launchpad.net/zodb/+bug/428039
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/Connection.py
  U   ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-04-26 18:31:22 UTC (rev 111452)
+++ ZODB/trunk/src/CHANGES.txt	2010-04-26 20:34:58 UTC (rev 111453)
@@ -26,14 +26,20 @@
 Bugs Fixed
 ----------
 
+- Fixed bug in cPickleCache's byte size estimation logic.
+  (https://bugs.launchpad.net/zodb/+bug/533015)
+
 - Fixed a serious bug that caused cache failures when run
   with Python optimization turned on.
 
   https://bugs.launchpad.net/zodb/+bug/544305
 
-- Fixed bug in cPickleCache's byte size estimation logic.
-  (https://bugs.launchpad.net/zodb/+bug/533015)
+- Fixed a bug that caused savepoint rollback to not properly
+  set object state when objects implemented _p_invalidate methods
+  that reloaded ther state (unghostifiable objects).
 
+  https://bugs.launchpad.net/zodb/+bug/428039
+
 - 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/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py	2010-04-26 18:31:22 UTC (rev 111452)
+++ ZODB/trunk/src/ZODB/Connection.py	2010-04-26 20:34:58 UTC (rev 111453)
@@ -1119,8 +1119,9 @@
         self._abort()
         self._registered_objects = []
         src = self._storage
-        self._cache.invalidate(src.index)
+        index = src.index
         src.reset(*state)
+        self._cache.invalidate(index)
 
     def _commit_savepoint(self, transaction):
         """Commit all changes made in savepoints and begin 2-phase commit

Modified: ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py	2010-04-26 18:31:22 UTC (rev 111452)
+++ ZODB/trunk/src/ZODB/tests/testConnectionSavepoint.py	2010-04-26 20:34:58 UTC (rev 111453)
@@ -154,6 +154,34 @@
     False
 """
 
+class SelfActivatingObject(persistent.Persistent):
+
+    def _p_invalidate(self):
+        super(SelfActivatingObject, self)._p_invalidate()
+        self._p_activate()
+
+def testInvalidateAfterRollback():
+    """\
+The rollback used to invalidate objects before resetting the TmpStore.
+This caused problems for custom _p_invalidate methods that would load
+the wrong state.
+
+    >>> import ZODB.tests.util
+    >>> db = ZODB.tests.util.DB()
+    >>> connection = db.open()
+    >>> root = connection.root()
+
+    >>> root['p'] = p = SelfActivatingObject()
+    >>> transaction.commit()
+    >>> p.foo = 1
+    >>> sp = transaction.savepoint()
+    >>> p.foo = 2
+    >>> sp2 = transaction.savepoint()
+    >>> sp.rollback()
+    >>> p.foo  # This used to wrongly return 2
+    1
+    """
+
 def tearDown(test):
     transaction.abort()
 



More information about the Zodb-checkins mailing list