mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
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 901af86550
.
This commit is contained in:
parent
901af86550
commit
4e9a74b81d
3 changed files with 1 additions and 34 deletions
|
@ -338,15 +338,6 @@ Miscellaneous
|
|||
needs. The new default value is `0666` (octal) and the current umask value
|
||||
is first masked out.
|
||||
|
||||
* In a multi-database situation, ``get_or_create()`` will now use a read
|
||||
database for the initial ``get`` attempt (previously, it used only the write
|
||||
database for all queries). This change reduces load on the write (master)
|
||||
database, in exchange for slightly more frequent false-negatives on the
|
||||
initial ``get`` due to replication lag. In those cases the subsequent insert
|
||||
will still go to the master and fail, after which the existing object will be
|
||||
fetched from the master.
|
||||
|
||||
|
||||
Features deprecated in 1.5
|
||||
==========================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue