Class PEER_LOCK


public class PEER_LOCK extends Locking
Implementation of a locking protocol which acquires locks by contacting all of the nodes of a cluster.

Unless a total order configuration is used (e.g. SEQUENCER based), lock requests for the same resource from different senders may be received in different order, so deadlocks can occur. Example:
 - Nodes A and B
 - A and B call lock(X) at the same time
 - A receives L(X,A) followed by L(X,B): locks X(A), queues L(X,B)
 - B receives L(X,B) followed by L(X,A): locks X(B), queues L(X,A)
 
To acquire a lock, we need lock grants from both A and B, but this will never happen here. To fix this, either add SEQUENCER to the configuration, so that all lock requests are received in the same global order at both A and B, or use Lock.tryLock(long,java.util.concurrent.TimeUnit) with retries if a lock cannot be acquired.

An alternative is also the CENTRAL_LOCK protocol.

Since:
2.12
Author:
Bela Ban
See Also: