#25432: Django ORM race condition
-------------------------------------+-------------------------------------
Reporter: yuvadm | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(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
-------------------------------------+-------------------------------------
Comment (by shaib):
> I have seen this happen in a test case where I make two subsequent API
calls that do exactly this and got a ~5% failure rate.
Can you elaborate on that a little? In particular, is the test case
using Django's test-client for these calls? If it is, there's one thread
on the server doing everything, and it all happens in the same
transaction; I'd ask you to check again about caching and replication and
that sort of thing.
If it isn't the test-client (or even the Django test framework), I'd ask
you to verify again that the second request is only sent after full
processing of the first request has completed.
Either way, please also verify that your PostgreSQL configuration is sane.
I've seen recommendations to make testing faster by turning off its fsync
etc, and that could be the cause of such behavior.
On a side note: I'm pretty sure get_or_create ''only'' works reliably
under serializable transactions; under the default (read-committed)
isolation level there are failure scenarios, whether you try to get first
or create first.
--
Ticket URL: <https://code.djangoproject.com/ticket/25432#comment:8>
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/064.dd0782c6e9b97a64b4f2beee527de683%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.