#16865: get_or_create defaults to _for_write even when it's just reading
-------------------------------------+-------------------------------------
Reporter: Rick van Hattem | Owner: nobody
<Rick.van.Hattem@…> | Status: closed
Type: Bug | Version: 1.3
Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Comment (by Carl Meyer <carl@…>):
In [changeset:"4e9a74b81df1c7aaea2f90a3a4911920e134b275"]:
{{{
#!CommitTicketReference repository=""
revision="4e9a74b81df1c7aaea2f90a3a4911920e134b275"
Revert "Fixed #16865 -- Made get_or_create use read database for initial
get query."
Thanks to Jeremy Dunck for pointing out the problem with this change. If
in a
single transaction, the master deletes a record and then get_or_creates a
similar record, under the new behavior the get_or_create would find the
record
in the slave db and fail to re-create it, leaving the record nonexistent,
which
violates the contract of get_or_create that the record should always exist
afterwards. We need to do everything against the master here in order to
ensure
correctness.
This reverts commit 901af865505310a70dd02ea5b3becbf45819b652.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16865#comment:14>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.