Are there any reputable libraries (with actual production references like 
Instagram) to deal with data concurrency, consistency and serializability?
A typical scenario is: a race condition caused by two clients. Suppose if 
someone had two browsers open and simultaneously click on [yes] from 
browser A and [no] from browser B.
I have seen the following 3 things mentioned by doing some google search:
1. use model.objects. select_for_update() with filter()
2. use django-concurrency library 
(https://github.com/saxix/django-concurrency)
3. use django-locking (https://github.com/stdbrouw/django-locking)
I can't find any production references for #2 and #3. I don't really want 
to apply some kind lab experiment even though they look good and a quick 
evaluation seems to do what they advertised.
As for #1, I'm thinking about using the following steps:
1. locking on some context object using select_for_update() with filter() 
within which I check for isOKToUpdate. release lock. If not ok, throw error 
immediately.
2. updateByClones. I will clone all the objects that I will update then 
update the clones.
3. locking on the same context object again and check isOKToUpdate again 
and this time I also do an atomic swap and commit if isOK. release lock. If 
not ok, throw error also.
In short, double locking with atomic swap. The locking is in a transaction 
with commit_on_ok. The locking block calls should be fairly fast because 
the context object is light weight with just a hash (some random string) to 
check whether someone else has updated or not.

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


Reply via email to