matthew.walters
matthew.walters

Reputation: 31

What causes Hazelcast to throw an InterruptedException during map.lock()

I'm using IMap to do locking, following how it's explained here:
https://groups.google.com/forum/#!topic/hazelcast/9YFGh3xwe8I

IMap<Object, Object> locks = hazelcastInstance.getMap("locks");
locks.lock(someStr);
try {
    //do stuff
} finally {
    locks.unlock(someStr);
}

Occasionally, the line

locks.locks(someStr)

Is causing the error

com.hazelcast.core.HazelcastException: java.lang.InterruptedException:
Call BasicInvocation{ serviceName='hz:impl:lockService',op=com.hazelcast.concurrent.lock.operations.LockOperation{
serviceName='hz:impl:lockService', callId=2854669, invocationTime=1441146297670, waitTimeout=-900001, callTimeout=60000}, 
partitionId=215, replicaIndex=0, tryCount=250, tryPauseMillis=500, invokeCount=0, callTimeout=60000, 
target=Address[*.*.*.*]:****, backupsExpected=0, backupsCompleted=0} was interrupted
at com.hazelcast.util.ExceptionUtil.rethrow(ExceptionUtil.java:52)
at com.hazelcast.spi.impl.BasicInvocationFuture.getSafely(BasicInvocationFuture.java:200)
at com.hazelcast.concurrent.lock.LockProxySupport.lock(LockProxySupport.java:79)
at com.hazelcast.concurrent.lock.LockProxySupport.lock(LockProxySupport.java:73)
at com.hazelcast.map.impl.proxy.MapProxyImpl.lock(MapProxyImpl.java:256)

The cluster in Production consists of two nodes.

I am unable to reproduce the issue locally.
I've read for a similar exception, it had to do with the app server clock times getting two far out of sync, but that is not the case for me.

Can anyone explain why this is happening?
It seems like my usage of IMap is very straightforward.

Upvotes: 0

Views: 2025

Answers (1)

boop
boop

Reputation: 21

Usually InterruptedException means that a thread that is executing locks.lock(someStr); was interrupted from some other thread of your program.

For example you can interrupt another thread with Thread.interrupt(), Future.cancel(true) or ExecutorService.shutdownNow().

Upvotes: 2

Related Questions