django/django — pull request #383 by trbs (2012-09-18 21:16:32+00:00)
Title: Fix #16865 get_or_create should only set _for_write when it's actually d...

...oing a create action.

This makes sure that the initial .get() will be able to use slave databases.
If there is replication lag it will fail when it tries to create the object on the master
and will still fetch the object. This is a trait off between extra selects when there is
no replication lag and extra transactions and rollback when there is replication lag.

Specially when some form of database pinning is in place this will help to not put all
the SELECT queries on the master. When somewhere in the code get_or_create is used.