scalahazelcast

Hazelcast - cannot make remote call: ContainsKeyOperation


The error is purely the title. Any call I do to containsKey in a map retrieved from Hazelcast I get this specific error. Example below:

val structuresMapStore : IMap[ String, Object ] = instance.getMap( MapNames.Structures )
if ( structuresMapStore.containsKey( uuidModel ) ) {
  logger.info( "\n\n Server - Dropping map: " + uuidModel + "\n\n" )
  structuresMapStore.remove( uuidModel )
  instance.getMap( uuidModel ).destroy()
  return "SUCCESS"
}
return "FAIL"

The stack after the exception

Aug 05, 2014 1:15:24 PM com.hazelcast.map.operation.ContainsKeyOperation
SEVERE: [192.168.122.1]:5701 [dev] [3.3-RC2] Thread[hz._hzInstance_2_dev.partition-    operation.thread-12,5,_hzInstance_2_dev] cannot make remote call: ContainsKeyOperation{}
java.lang.IllegalThreadStateException: Thread[hz._hzInstance_2_dev.partition-operation.thread-12,5,_hzInstance_2_dev] cannot make remote call: ContainsKeyOperation{}
at com.hazelcast.spi.impl.BasicInvocation.invoke(BasicInvocation.java:230)
at com.hazelcast.spi.impl.BasicOperationService.invokeOnPartition(BasicOperationService.java:237)
at com.hazelcast.map.proxy.MapProxySupport.containsKeyInternal(MapProxySupport.java:560)
at com.hazelcast.map.proxy.MapProxyImpl.containsKey(MapProxyImpl.java:236)
at com.utils.hazelcast.HazelcastUtils$.getPersistence(HazelcastUtils.scala:14)
at com.utils.hazelcast.mapstore.UniDataModelMapStore.load(UniDataModelMapStore.scala:31)
at com.utils.hazelcast.mapstore.UniDataModelMapStore.load(UniDataModelMapStore.scala:18)
at com.hazelcast.map.MapStoreWrapper.load(MapStoreWrapper.java:121)
at com.hazelcast.map.mapstore.writethrough.WriteThroughStore.load(WriteThroughStore.java:78)
at com.hazelcast.map.mapstore.writethrough.WriteThroughStore.load(WriteThroughStore.java:31)
at com.hazelcast.map.DefaultRecordStore.containsKey(DefaultRecordStore.java:603)
at com.hazelcast.map.operation.ContainsKeyOperation.run(ContainsKeyOperation.java:33)
at com.hazelcast.spi.impl.BasicOperationService$OperationHandler.handle(BasicOperationService.java:673)
at com.hazelcast.spi.impl.BasicOperationService$OperationHandler.access$400(BasicOperationService.java:649)
at com.hazelcast.spi.impl.BasicOperationService$BasicDispatcherImpl.dispatch(BasicOperationService.java:527)
at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.process(BasicOperationScheduler.java:428)
at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.doRun(BasicOperationScheduler.java:422)
at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.run(BasicOperationScheduler.java:397)

The error occurs when I call containsKey inside if statement.


Solution

  • It is not allowed to make operations from MapStore interface methods in case of write through. Because writethrough map store operations run on partition thread, and using another partition based operation(like Containskey) can cause deadlock. That is why we have a check and an exception there.