fix session's commit handling: when an operation failed in [pre]commit, call rollback_event as well for already processed operation, not only the revert<event> callback stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 08 Feb 2010 13:03:38 +0100
branchstable
changeset 4497 593386221aa7
parent 4496 14cbf2570ce8
child 4498 ee6362b4618d
child 4500 81021d62138f
fix session's commit handling: when an operation failed in [pre]commit, call rollback_event as well for already processed operation, not only the revert<event> callback
server/session.py
--- a/server/session.py	Mon Feb 08 13:02:05 2010 +0100
+++ b/server/session.py	Mon Feb 08 13:03:38 2010 +0100
@@ -461,9 +461,21 @@
                     self.debug('%s session %s done', trstate, self.id)
                 except:
                     self.exception('error while %sing', trstate)
+                    # if error on [pre]commit:
+                    #
+                    # * set .failed = True on the operation causing the failure
+                    # * call revert<event>_event on processed operations
+                    # * call rollback_event on *all* operations
+                    #
+                    # that seems more natural than not calling rollback_event
+                    # for processed operations, and allow generic rollback
+                    # instead of having to implements rollback, revertprecommit
+                    # and revertcommit, that will be enough in mont case.
                     operation.failed = True
                     for operation in processed:
                         operation.handle_event('revert%s_event' % trstate)
+                    # res
+                    self.pending_operations = processed + self.pending_operations
                     self.rollback(reset_pool)
                     raise
             self.pool.commit()