Search code examples
javajboss6.xinfinispan

Infinispan remote lazy locking


We are using Infinispan 4.0 as our caching provider ( i know it's kind of antique as version 9 is the latest ). That being said , i am a little bit confused while reading the documentation that states :

Infinispan, by default, acquires remote locks lazily. Locks are acquired locally on a node that runs a transaction while other cluster nodes attempt to lock cache keys involved in a transaction during two-phase prepare/commit phase. However, if desired, Infinispan can eagerly lock cache keys either explicitly or implicitly.

What is the default behavior of Infinispan ? I understand that it locks only on the local node but exactly when does it lock on the cluster ? For example if you have an operation like :

Cache.put(K,V)

How does it behave when another node in the cluster attempts a concurrent

Cache.put(K,V)

operation? How does this remote lazy locking work ?


Solution

  • That comment was about transactions. With transactions, the remote locks could be acquired either during cache.put(k, v) (eager) or during tm.commit() (lazy). Without transactions, there's no distinction between the two.

    Note that the locking in 4.x was very prone to deadlocks. A node would acquire the local lock, then it would try to acquire the locks on all the other owners, and there was a high chance of a deadlock if another node tried to write to the same key concurrently.