Opened 7 years ago
Closed 7 years ago
#28836 closed Cleanup/optimization (needsinfo)
Not nesting version of @atomic decorator
Reported by: | Thomas Güttler | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Database transaction can't be nested.
Database transactions are ACID. And D stand for durability.
I think it is dangerous that the current implementation of @atomic falls back to savepoints, if
already inside a transaction.
I don't want to change the current default.
But I would like to have a decorator which raises an exception if the connection is already inside a transaction.
I don't care how the implementation looks like. I see two way:
- a new method. For example @non_nesting_atomic
- a kwarg: For example @atomic(non_nesting=True) with a default of "False" for backward compatibility.
What do you think?
Change History (2)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Resolution: | → needsinfo |
Status: | new → closed |
Type: | Uncategorized → Cleanup/optimization |
Note:
See TracTickets
for help on using tickets.
The name
@atomic
was chosen to focus on A (atomicity).The current way to check if you're in a transaction is the following:
... which is less than intuitive, sorry.
I don't have a clear opinion on the suggestion you're making.