[Checkins] SVN: transaction/trunk/ Bug fixed:

Jim Fulton jim at zope.com
Wed May 12 13:15:19 EDT 2010


Log message for revision 112260:
  Bug fixed:
  
  * Fixed a bug that caused extra commit calls to be made on data
    managers under certain special circumstances.
  
  https://mail.zope.org/pipermail/zodb-dev/2010-May/013329.html
  

Changed:
  U   transaction/trunk/CHANGES.txt
  U   transaction/trunk/transaction/_transaction.py
  U   transaction/trunk/transaction/tests/test_savepoint.py

-=-
Modified: transaction/trunk/CHANGES.txt
===================================================================
--- transaction/trunk/CHANGES.txt	2010-05-12 17:15:17 UTC (rev 112259)
+++ transaction/trunk/CHANGES.txt	2010-05-12 17:15:19 UTC (rev 112260)
@@ -1,12 +1,16 @@
 Changes
 =======
 
-1.0.2 (unreleased)
-------------------
+1.1.0 (1010-05-??)
 
-- TBD
+Bugs fixed:
+=======
 
+- Fixed a bug that caused extra commit calls to be made on data
+  managers under certain special circumstances.
 
+  https://mail.zope.org/pipermail/zodb-dev/2010-May/013329.html
+
 1.0.1 (2010-05-07)
 ------------------
 
@@ -15,25 +19,24 @@
 
 - Updated tests to remove use of deprecated ``zope.testing.doctest``.
 
-
 1.0.0 (2009-07-24)
 ------------------
 
-* Fix test that incorrectly relied on the order of a list that was generated
+- Fix test that incorrectly relied on the order of a list that was generated
   from a dict.
 
- * Remove crufty DEPENDENCIES.cfg left over from zpkg.
+- Remove crufty DEPENDENCIES.cfg left over from zpkg.
 
 1.0a1 (2007-12-18)
 ------------------
 
-* Initial release, branched from ZODB trunk on 2007-11-08 (aka
+= Initial release, branched from ZODB trunk on 2007-11-08 (aka
   "3.9.0dev").
 
-* Remove (deprecated) support for beforeCommitHook alias to
+- Remove (deprecated) support for beforeCommitHook alias to
   addBeforeCommitHook.
 
-* Add weakset tests.
+- Add weakset tests.
 
-* Remove unit tests that depend on ZODB.tests.utils from
+- Remove unit tests that depend on ZODB.tests.utils from
   test_transaction (these are actually integration tests).

Modified: transaction/trunk/transaction/_transaction.py
===================================================================
--- transaction/trunk/transaction/_transaction.py	2010-05-12 17:15:17 UTC (rev 112259)
+++ transaction/trunk/transaction/_transaction.py	2010-05-12 17:15:19 UTC (rev 112260)
@@ -242,6 +242,13 @@
                 transaction_savepoint._savepoints.append(
                     datamanager_savepoint)
 
+    def _unjoin(self, resource):
+        # Leave a transaction because a savepoint was rolled back on a resource
+        # that joined later.
+
+        # Don't use remove.  We don't want to assume anything about __eq__.
+        self._resources = [r for r in self._resources if r is not resource]
+
     def savepoint(self, optimistic=False):
         if self.status is Status.COMMITFAILED:
             self._prior_operation_failed() # doesn't return, it raises
@@ -669,6 +676,7 @@
 
     def rollback(self):
         self.datamanager.abort(self.transaction)
+        self.transaction._unjoin(self.datamanager)
 
 class NoRollbackSavepoint:
 

Modified: transaction/trunk/transaction/tests/test_savepoint.py
===================================================================
--- transaction/trunk/transaction/tests/test_savepoint.py	2010-05-12 17:15:17 UTC (rev 112259)
+++ transaction/trunk/transaction/tests/test_savepoint.py	2010-05-12 17:15:19 UTC (rev 112260)
@@ -12,8 +12,6 @@
 #
 ##############################################################################
 """Tests of savepoint feature
-
-$Id$
 """
 import unittest
 import doctest
@@ -33,7 +31,7 @@
     >>> sp1 = transaction.savepoint()
     >>> dm['job'] = 'geek'
     >>> sp2 = transaction.savepoint()
-    >>> dm['salary'] = 'fun'    
+    >>> dm['salary'] = 'fun'
     >>> dm2 = savepointsample.SampleSavepointDataManager()
     >>> dm2['name'] = 'sally'
 
@@ -59,6 +57,27 @@
 
 """
 
+def test_commit_after_rollback_for_dm_that_joins_after_savepoint():
+    """
+
+There was a problem handling data managers that joined after a
+savepoint.  If the savepoint was rolled back and then changes made,
+the dm would end up being joined twice, leading to extra tpc calls and pain.
+
+    >>> import transaction
+    >>> sp = transaction.savepoint()
+    >>> from transaction.tests import savepointsample
+    >>> dm = savepointsample.SampleSavepointDataManager()
+    >>> dm['name'] = 'bob'
+    >>> sp.rollback()
+    >>> dm['name'] = 'Bob'
+    >>> transaction.commit()
+    >>> dm['name']
+    'Bob'
+    """
+
+
+
 def test_suite():
     return unittest.TestSuite((
         doctest.DocFileSuite('savepoint.txt'),



More information about the checkins mailing list