afterCommitHook not called on abort

Bug #137739 reported by Christian Zagrodnick
2
Affects Status Importance Assigned to Milestone
ZODB
Invalid
Medium
Christian Zagrodnick

Bug Description

the documentation in the _transaction.py reads:

After-commit hook
------------------

Sometimes, applications want to execute code after a transaction is
committed or aborted. [...] The callable will be called with a Boolean
value representing the status of the commit operation as first
argument (true if successfull or false iff aborted) [...]

And indeed in the commit() method it reads:

        try:
            self._commitResources()
            self.status = Status.COMMITTED
        except:
            t, v, tb = self._saveAndGetCommitishError()
            self._callAfterCommitHooks(status=False)
            raise t, v, tb
        else:
            if self._manager:
                self._manager.free(self)
            self._synchronizers.map(lambda s: s.afterCompletion(self))
            self._callAfterCommitHooks(status=True)

But in the abort() method the hooks are not called.

Is this intentional? If yes, the documentation should be adjusted to reflect that the hooks are *only* called if there *is* a commit and it is *failing*.

If not the hooks should be called in abort (my favourite) :)

Changed in zodb:
status: New → Confirmed
Revision history for this message
Christian Theune (ctheune) wrote :

Zagy's been implementing this for 3.9 (trunk) on a branch. It needs to be discussed whether we can backport to 3.8.

Changed in zodb:
assignee: nobody → zagy
status: Confirmed → In Progress
Changed in zodb:
importance: Undecided → Medium
status: In Progress → Incomplete
Revision history for this message
Christian Zagrodnick (zagy) wrote :

Will not go to trunk. Thie behaviour will be changed to using an event system in the future. Marking this one invalid.

Changed in zodb:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.