[Django] #25939: Remove transaction from QuerySet.update_or_create's save()

12 views
Skip to first unread message

Django

unread,
Dec 14, 2015, 6:32:33 PM12/14/15
to django-...@googlegroups.com
#25939: Remove transaction from QuerySet.update_or_create's save()
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: Ready for | Has patch: 1
checkin |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
According to Aymeric on [https://github.com/django/django/pull/5804 the
pull request]:

It will have beneficial performance effects if:
* `ATOMIC_REQUESTS` is not in use
* `update_or_create` ends up creating an object
* the `save` method of that objects does long things like sending email
after the write (i.e. once it holds an exclusive lock on the database)

--
Ticket URL: <https://code.djangoproject.com/ticket/25939>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 14, 2015, 7:42:21 PM12/14/15
to django-...@googlegroups.com
#25939: Remove transaction from QuerySet.update_or_create's save()
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"423b3afce431fd0a1d683bca9b2b80a1c4e3c8ca" 423b3afc]:
{{{
#!CommitTicketReference repository=""
revision="423b3afce431fd0a1d683bca9b2b80a1c4e3c8ca"
Fixed #25939 -- Removed redundant transaction in
QuerySet.update_or_create().

There is no need to wrap the save() call in transaction.atomic() as
it's already done down the call stack in Model.save_base().
}}}

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

Reply all
Reply to author
Forward
0 new messages