#24446: ATOMIC_REQUESTS add extra queries if the view was already in a
transaction
-------------------------------------+-------------------------------------
Reporter: diox | Owner: nobody
Type: Bug | Status: new
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 aaugustin):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I discussed this with diox yesterday on IRC and suggested this patch which
appears to fix the issue:
{{{
diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py
index e40eb2f..92ad394 100644
--- a/django/core/handlers/base.py
+++ b/django/core/handlers/base.py
@@ -78,7 +78,7 @@ class BaseHandler(object):
for db in connections.all():
if (db.settings_dict['ATOMIC_REQUESTS']
and db.alias not in non_atomic_requests):
- view = transaction.atomic(using=db.alias)(view)
+ view = transaction.atomic(using=db.alias,
savepoint=False)(view)
return view
def get_exception_response(self, request, resolver, status_code):
}}}
I think this change is for the better, however there's a potential for
backwards incompatibility. If some developers went through the pain of
adding 2 to all their `assertNumQueries`, forcing them to substract 2
again isn't nice...
That said, if I remember correctly, I had found a solution during the
transaction refactor to avoid breaking `assertNumQueries`, so I'm not sure
why diox is seeing this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/24446#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/062.125cfec04420682dcb589ffcde3bfdac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.