#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: nobody
(Chainz) Johnson |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
As discussed [https://twitter.com/IanFooteTech/status/1329793500674732035
on Twitter] following [https://seddonym.me/2020/11/19/trouble-atomic/
David Seddon's blog post].
`transaction.atomic()` guarantees the wrapped database operations is
*atomic* - at the end of its wrapped block, operations within that block
will all be applied, or all rolled back. In some situations it's also
useful to guarantee that the wrapped operations are *durable* - at the end
of the wrapped block, all operations have definitely been committed.
`atomic()` doesn't guarantee this at the moment since its use may be
wrapped by *another* `atomic()` higher in the stack, delaying the commit.
David Seddon's technique to guarantee durability is to wrap `atomic()` to
first check if an `atomic()` is already active for the current connection
(in other words, `connection.get_autocommit()` returns `False`), and raise
an error if so.
On Twitter, Ian Foote suggested adding a `durable` flag to `atomic()` to
add this behaviour to Django, to which Aymeric Augustin said it sounds
like a good idea.
--
Ticket URL: <https://code.djangoproject.com/ticket/32220>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.b438b98fbde1b8220f8fe00f2e6d89e9%40djangoproject.com.