#20571: Using savepoints within transaction.atomic() can result in the entire
transaction being incorrectly and silently rolled back
-------------------------------------+-------------------------------------
Reporter: lamby | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version:
Component: Documentation | 1.6-alpha-1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by aaugustin):
* type: Bug => Cleanup/optimization
* component: Database layer (models, ORM) => Documentation
Comment:
One solution is to remove the `savepoint=False` option. But it was
included for two good reasons:
- it improves performance,
- it avoids breaking all assertNumQueries with extra SAVEPOINT / RELEASE
SAVEPOINT queries.
Another solution is to discourage using the low level API. Technically,
the inner block in the example above is strictly equivalent to:
{{{
with transaction.atomic():
User.objects.create(pk=user.pk)
}}}
I'm in favor of the second solution because I still have to see a use case
that isn't covered by `transaction.atomic()`. There aren't many patterns
for using savepoints in an application.
--
Ticket URL: <https://code.djangoproject.com/ticket/20571#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.23404bd2db607b66b8069d4435933063%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.