#29499: Race condition in QuerySet.update_or_create()
-------------------------------------+-------------------------------------
Reporter: Michael Sanders | Owner: Michael
| Sanders
Type: Bug | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: race-condition | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):
In [changeset:"6cfe00ee438111af38f1e414bd01976e23b39715" 6cfe00e]:
{{{#!CommitTicketReference repository=""
revision="6cfe00ee438111af38f1e414bd01976e23b39715"
Refs #29499 -- Fixed race condition in update_or_create() test.
The usage of time.sleep() could result in the update_or_create() thread
winning
the race to create the row if the backend takes a while to create a new
connection in the main thread.
Relying on threading.Event ensures that the flow of execution is
systematically
yield back and forth between the main thread and the thread in charge of
performing the background update_or_create().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29499#comment:13>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/010701946a657a4f-123cb009-898c-403b-8fe0-15313e25fd2a-000000%40eu-central-1.amazonses.com.