You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have reduced the issue to the simplest possible case.
I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
Wrap a view that errors with @non_atomic_requests, but use a transaction around it somehow. The easiest way is to test it from a Django TestCase, which uses transactions around each test. Another way would be to have a custom middleware that does a transaction a different way.
Expected behavior
rest_framework.set_rollback should not call transaction.set_rollback because the view is declared as non-atomic.
Actual behavior
rest_framework.set_rollback calls transaction.set_rollback. Its check for "is this view non-atomic" checks connection.in_atomic_block which as indicated above can be true for a number of reasons.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
[-]set_rollback() isn't multi-DB aware[/-][+]set_rollback's atomic check is inaccurate[/+]Improve set_rollback() behaviour
Improve set_rollback() behaviour
Improve set_rollback() behaviour
sww314 commentedon May 5, 2021
I am seeing this on DRF 3.12
When using a
@transaction.non_atomic_requests, I get an transaction error. I am also using a multi-db solution.stale commentedon Apr 29, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Oct 19, 2025
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.