[Django] #32220: Add a 'durable' flag to transaction.atomic()

48 views
Skip to first unread message

Django

unread,
Nov 22, 2020, 4:01:37 AM11/22/20
to django-...@googlegroups.com
#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.

Django

unread,
Nov 22, 2020, 10:39:08 AM11/22/20
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Ian Foote
Johnson |
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ian Foote):

* owner: nobody => Ian Foote
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:1>

Django

unread,
Nov 22, 2020, 11:50:09 AM11/22/20
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Ian Foote
Johnson |
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ian Foote):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:2>

Django

unread,
Nov 22, 2020, 2:44:09 PM11/22/20
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Ian Foote
Johnson |
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:3>

Django

unread,
Nov 26, 2020, 2:16:54 AM11/26/20
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Ian Foote
Johnson |
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:4>

Django

unread,
Nov 27, 2020, 2:53:59 AM11/27/20
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Ian Foote
Johnson |
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:5>

Django

unread,
Nov 28, 2020, 1:32:57 AM11/28/20
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Ian Foote
Johnson |
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3828879eee09da95bf99886c1ae182a36b1d89b3" 3828879e]:
{{{
#!CommitTicketReference repository=""
revision="3828879eee09da95bf99886c1ae182a36b1d89b3"
Fixed #32220 -- Added durable argument to transaction.atomic().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:6>

Django

unread,
Mar 24, 2021, 2:48:24 PM3/24/21
to django-...@googlegroups.com
#32220: Add a 'durable' flag to transaction.atomic()
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Ian Foote

Type: New feature | Status: closed
Component: Database layer | Version: dev

(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Alex Rattray):

Recently filed a related ticket to allow this or similar behavior to be
default: https://code.djangoproject.com/ticket/32590

--
Ticket URL: <https://code.djangoproject.com/ticket/32220#comment:7>

Reply all
Reply to author
Forward
0 new messages