I can think of two approaches:

1. Let all threads read the data (in parallel) and use transaction to update
the data. Transaction will fail for all the thread except for one. Threads
with failed transaction will again read data, recompute the things and try
to update the data again.

2. Implement a global locking scheme - Make a dummy entity with a field of
type boolean. Take true == "lock acquired" & false == "lock free". A thread
which is trying to update the data will have to acquire the lock before
reading data. To acquire a lock a thread will try to set lock = true, using
transaction. If lock is already taken, thread will wait for the locking
thread to release the lock.

In the second case, number of datastore reads can be reduced by caching lock
entity in memcache.

--
Prashant
http://code.google.com/p/claymus/

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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/google-appengine?hl=en.

Reply via email to