Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32220 closed New feature (fixed)

Add a 'durable' flag to transaction.atomic()

Reported by: Adam Johnson Owned by: Ian Foote
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As discussed on Twitter following 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.

Change History (7)

comment:1 by Ian Foote, 4 years ago

Owner: changed from nobody to Ian Foote
Status: newassigned

comment:2 by Ian Foote, 4 years ago

Has patch: set

comment:3 by Mariusz Felisiak, 4 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Mariusz Felisiak, 4 years ago

Patch needs improvement: set

comment:5 by Mariusz Felisiak, 4 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 3828879e:

Fixed #32220 -- Added durable argument to transaction.atomic().

comment:7 by Alex Rattray, 4 years ago

Recently filed a related ticket to allow this or similar behavior to be default: #32590

Last edited 4 years ago by Tim Graham (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top