Has anyone tried to implement pessimistic locking on GAE? On my project there are some tasks that have to be mutually exclusive. I have done this by using:
javax.persistence.EntityManager.find(entityClass, primaryKey, LockModeType.PESSIMISTIC_READ);
which queries DB using SELECT FOR UPDATE and which works well ... as long as there is only one application instance that is processing the requests. If there were more instances my requests would be processed partially concurrently.
I have tested this by adding a sleep of 10 seconds inside of my mutually exclusive method. For one instance 6 requests were processed in about 60 seconds but for 3 instances sometimes 20 sometimes 30 but never 60 seconds.
Does it mean CloudSQL does not replicate Locks among SQL instances? Is there any other way to implement pessimistic locking on a table row ?
Br Marek