#26804: update_or_create() updates all columns, which could cause a race
condition
-------------------------------------+-------------------------------------
Reporter: jensen-cochran | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: update_or_create | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shaib):
* stage: Unreviewed => Accepted
Comment:
No, actually locking the row is the only valid solution. Otherwise you
still have a race condition -- when someone else updates the record, it is
possible that your `update_or_create` should be creating a new row rather
than updating the existing one. IMO the right fix is to change the row
{{{
obj = self.get(**lookup)
}}}
into
{{{
obj = self.select_for_update().get(**lookup)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26804#comment:2>
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/072.977b3b493484c243fbd3ad5543f12a5a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.