Description
We're using the LockRegistryLeaderInitiator
mechanism to control leader election in the cluster backed with Hazelcast. I see that it uses tryLock(long time, TimeUnit unit)
method without specifying the maximum lease time. In fact, it's possible that without graceful shutdown the instance won't release the lock and then no other leader will be elected. All instances then are logging
Acquiring the lock for LockContext{role=my-app-leader, id={{app-uuid}}, isLeader=false}
Without manually forcing unlock the whole cluster is stuck. I know that the java.util.concurrent.locks.Lock
doesn't offer locking for a given time, but it's supported for example with the com.hazelcast.core.ILock.tryLock(long time, TimeUnit unit, long leaseTime, TimeUnit leaseUnit)
method.
Maybe simple possibility to override LeaderSelector.call
lock acquisition part could be extracted so users can override it with and provide max lease time for example? It could be also done for example in the spring-integration-hazelcast
module.