I have faced dead lock problem while writing into cache by multiple threads in pessimistic locking. So i have changed node locking scheme to optimistic locking . I saw in the forum that it solves the concurrency problem.But still i am getting dead lock and lock time out exception.
Basically when CacheInstance1 commits a tx, it issues a local prepare (already holds locks on the nodes) and broadcasts a remote prepare to acquire locks on the other cache instances.
If at the same time, CacheInstance2 commits a tx ON THE SAME DATA (acquires local locks before CacheInstance1's remote prepare is received) and attempts to do a remote prepare, both caches will deadlock since they both want locks on each other's data.