Opened 12 years ago
Closed 12 years ago
#18449 closed Bug (duplicate)
Having an error raised during a transaction-decorated view will drop the error on the floor
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.4 |
Severity: | Normal | Keywords: | transaction |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Consider:
@commit_manually def my_view(): transaction.set_dirty() # or a DB call or something raise Exception("asdf")
As the transaction is dirty, when exiting the decorator, it will raise an exception because the transaction is dirty. Duh. Instead, if there is an exc_value set in the exiting function, Django should re-raise it immediately and not drop my exception on the floor.
Change History (4)
comment:1 by , 12 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Keywords: | transaction added |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:2 by , 12 years ago
Triage Stage: | Accepted → Design decision needed |
---|
The way commit_manually works is that you must either commit or rollback the transaction. This is explicitly documented. So, the given TransactionManagementError
is more like a hint saying that you are using the commit_manually decorator improperly.
I don't think this should be changed in a way where the original exception is risen and no hint is given. This could be a source of transaction leak. There might be some point of changing the decorator to do automatic rollback on exceptions. This would be a change from currently documented behavior.
As currently documented, the reported problem is an user error. If the currently documented behavior should be changed needs a design decision.
comment:3 by , 12 years ago
Since I filed this bug, I found a duplicate somewhere with a patch. I cannot find it again for the life of me, sorry.
Here's the same problem shown in a shell:
At first sight, it would be more logical (and easier to debug) if the original exception wasn't swallowed. I'd like if someone familiar with transaction management could confirm.