Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-2408

Apply state results in ClassCastException with pessimistic locking

    XMLWordPrintable

Details

    Description

      The putIfAbsent command executed for applying state received from neighbours during state transfer used to be done with SKIP_LOCKING flag in 5.2.Beta1.

      Considering that putIfAbsent cannot provide sufficient guarantees without locking I removed the SKIP_LOCKING flag in 5.2.Beta2.

      Unfortunately this means that the non-Tx remote context we use for apply state is no longer suitable. PessimisticLockingInterceptor expects a transactional context and this causes all puts to fail and log an exception. State transfer is basically not able to transfer any data for pessimistic caches.

      A quick workaround is to put back SKIP_LOCKING from where it was removed. See line 298: https://github.com/infinispan/infinispan/blob/7ee1ce5a186928b740f4cf9f3751139ca734dd88/core/src/main/java/org/infinispan/statetransfer/StateConsumerImpl.java#L298

      But this workaround is not correct. SKIP_LOCKING may cause uncertain results with putIfAbsent.

      2012-10-15 19:46:35,680 WARN  [StateConsumerImpl] (OOB-1,ISPN,NodeC-26225) ISPN000016: Problem org.infinispan.context.impl.NonTxInvocationContext cannot be cast to org.infinispan.context.impl.TxInvocationContext encountered when applying state for key MagicKey{hashcode=153290881, address='NodeA-9763'}!
      2012-10-15 19:46:35,680 TRACE [InvocationContextInterceptor] (OOB-1,ISPN,NodeC-26225) Invoked with command PutKeyValueCommand{key=MagicKey{hashcode=-764090028, address='NodeA-9763'}, value=MagicKey{hashcode=-764090028, address='NodeA-9763'}, flags=[CACHE_MODE_LOCAL, SKIP_SHARED_CACHE_STORE, SKIP_OWNERSHIP_CHECK, IGNORE_RETURN_VALUES, SKIP_XSITE_BACKUP], putIfAbsent=true, lifespanMillis=-1, maxIdleTimeMillis=-1} and InvocationContext [org.infinispan.context.impl.NonTxInvocationContext@625cb0bb]
      2012-10-15 19:46:35,680 ERROR [InvocationContextInterceptor] (OOB-1,ISPN,NodeC-26225) ISPN000136: Execution error
      java.lang.ClassCastException: org.infinispan.context.impl.NonTxInvocationContext cannot be cast to org.infinispan.context.impl.TxInvocationContext
      	at org.infinispan.interceptors.locking.PessimisticLockingInterceptor.visitPutKeyValueCommand(PessimisticLockingInterceptor.java:114)
      	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
      	at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
      	at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:63)
      	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
      	at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:212)
      	at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:150)
      	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
      	at org.infinispan.statetransfer.StateTransferInterceptor.handleTopologyAffectedCommand(StateTransferInterceptor.java:203)
      	at org.infinispan.statetransfer.StateTransferInterceptor.handleWriteCommand(StateTransferInterceptor.java:189)
      	at org.infinispan.statetransfer.StateTransferInterceptor.visitPutKeyValueCommand(StateTransferInterceptor.java:135)
      	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
      	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
      	at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:129)
      	at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:93)
      	at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:63)
      	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:77)
      	at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:347)
      	at org.infinispan.statetransfer.StateConsumerImpl.doApplyState(StateConsumerImpl.java:306)
      	at org.infinispan.statetransfer.StateConsumerImpl.applyState(StateConsumerImpl.java:264)
      	at org.infinispan.statetransfer.StateResponseCommand.perform(StateResponseCommand.java:86)
      	at org.infinispan.remoting.InboundInvocationHandlerImpl.handleInternal(InboundInvocationHandlerImpl.java:95)
      	at org.infinispan.remoting.InboundInvocationHandlerImpl.handleWithWaitForBlocks(InboundInvocationHandlerImpl.java:110)
      	at org.infinispan.remoting.InboundInvocationHandlerImpl.handle(InboundInvocationHandlerImpl.java:82)
      	at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.executeCommandFromLocalCluster(CommandAwareRpcDispatcher.java:244)
      	at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:217)
      	at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:483)
      	at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:390)
      	at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:248)
      	at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:604)
      	at org.jgroups.JChannel.up(JChannel.java:670)
      	at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1020)
      	at org.jgroups.protocols.FRAG2.up(FRAG2.java:181)
      	at org.jgroups.protocols.FC.up(FC.java:479)
      	at org.jgroups.protocols.pbcast.GMS.up(GMS.java:896)
      	at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:244)
      	at org.jgroups.protocols.UNICAST2.handleDataReceived(UNICAST2.java:736)
      	at org.jgroups.protocols.UNICAST2.up(UNICAST2.java:414)
      	at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:601)
      	at org.jgroups.protocols.Discovery.up(Discovery.java:359)
      	at org.jgroups.protocols.TP.passMessageUp(TP.java:1293)
      	at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1856)
      	at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1829)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:662)
      

      Attachments

        Activity

          People

            anistor Adrian Nistor
            anistor Adrian Nistor
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: