The exception is thrown if self.needs_rollback is True, but the underlying
reason that self.needs_rollback has been set True has been lost, since it
could have happened a long time previously.
Transactions should keep track of why needs_rollback has been set, and use
that to provide a more helpful error.
Background: I'm seeing this error being thrown when a task is run on a
Celery queue, but not when run manually. Since it's via Celery, dropping
into the debugger is impossible, and thus I'm back to trying to dump
useful debug info.
--
Ticket URL: <https://code.djangoproject.com/ticket/23353>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Accepting the general idea, but I'm not sure how that would work in
practice.
--
Ticket URL: <https://code.djangoproject.com/ticket/23353#comment:1>
Comment (by Simon Charette):
I guess we could track the original exception and set it as the
`__cause__` of the `TransactionManagementError`.
--
Ticket URL: <https://code.djangoproject.com/ticket/23353#comment:2>
* cc: David Wobrock (added)
* owner: nobody => David Wobrock
* has_patch: 0 => 1
* status: new => assigned
Comment:
Beginners often struggle understanding the root cause when a
`TransactionManagementError` occurs.
Here's a patch [https://github.com/django/django/pull/16143 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/23353#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/23353#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3b4a5b9f97f113ca5151cff744019e39a1ed7475" 3b4a5b9f]:
{{{
#!CommitTicketReference repository=""
revision="3b4a5b9f97f113ca5151cff744019e39a1ed7475"
Fixed #23353 -- Used "raise from" when raising TransactionManagementError.
This change sets the __cause__ attribute to raised exceptions.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23353#comment:5>