1 Reply Latest reply on Oct 31, 2016 10:50 AM by rvansa

    Distributed locks


      I am looking to use locks with a distributed cache for coordination. I have a couple general questions on usage. First, is there any sort of expiration associated with locks such that the holder has to renew or refresh?


      Suppose I have clients A, B, and C with each trying to acquire a lock. A gets the lock but goes down. I assume the lock will get released, but how long will it be before B or C can acquire the lock?


      Let's say there is a split-brain scenario in which both A and B think they have acquired the lock? How is that situation resolved?




      - John

        • 1. Re: Distributed locks

          What distributed locks do you have in mind? Infinispan does not really offer any locking API, though it exposes the locks used to guard access to entries in pessimistic transactional cache. The is distributed locks API in JGroups but you should use different forum for that.


          Speaking about locks in Infinispan, if you lock an entry during a transaction, it's locked until tx is committed or rolled back. TM usually has some timeout for the transaction and triggers a rollback if user does not complete the transaction explicitly - by default this is 1 minute with JBoss TM. So it's a responsibility of TM (on the origin node) to release the locks by doing rollback.

          When a node leaves the cluster, all pending transactions originating on that node are cancelled. The suspect timeout depends on your JGroups settings, protocols FD* and VERIFY_SUSPECT handle that, plus there's some delay until the information propagates through Infinispan (but this is usually < 1s). See http://jgroups.org/manual/index.html#FailureDetection 

          Also, there's a periodic process searching for timed out transactions on each node - you can control transaction timeout and the period of the process through <transaction ... complete-timeout="60000" reaper-interval="30000" />