On Aug 8, 2012 10:25 AM, "Cal Leeming [Simplicity Media Ltd]" <
[email protected]> wrote:
>
> I'm not entirely sure that suggesting every query needs to be committed
is the right way forward either, given that you only need to commit once
before get_or_create() is called to prevent the issue.

No, that's not sufficient. The crux of the problem is that the two get
attempts within get_or_create are within the same transaction, and so to
satisfy the requirements of REPEATABLE READ they *must* return the same
results. So it's not enough just to start with a clean transaction; in
order to prevent this you would need to commit or rollback between the two
gets, *within* the get_or_create call. MySQL actually does handle this much
correctly AFAICT. The weirdness is just that it defaults to RR instead of
RC.

Resorting to database-level autocommit would be overkill (and might create
some other issues), but it does solve this particular problem by adding the
necessary commit in the one place it's needed.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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 this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to