2 Replies Latest reply on May 26, 2011 4:13 AM by ghostho

    Execution error : TimeOutException unable to acquire lock after

    ghostho Newbie

      Hello,

       

      i try to lock an entry before i added an entry and lock an entry before i get it. But when i put an key, then it will be locked. I dont get the key because it is locked. This is ok, but i get an exception.

       

      PC1 -> 1. try to put an key then lock it and wait

      PC2 -> 2. try to get the key, it doesnt because its locked from PC1.  Its also ok but i get an exception.


      My goal is to tell me the key is locked, when i want this key. I dont want an exception. I also dont want a timeout.  Can anybody help me ??

       

       

      Put an entry

       

      tm = cache.getAdvancedCache().getTransactionManager();

                      logger.info("Key:");

                      tmp1 = eingabe.next();

                     

                      tm.begin();

                      try {

                         

                          boolean tmp = cache.getAdvancedCache().lock(tmp1);

                          if (tmp) {

                              logger.info("Value:");

                              String tmp2 = eingabe.next();

                              cache.put(tmp1, tmp2);

                              tm.commit();

                          } else {

                              logger.info("Key is locked !");

                              tm.rollback();

                          }

                      } catch (org.infinispan.util.concurrent.TimeoutException e) {

                          tm.rollback();

                      }

       

       

      get an entry

       

      tm = cache.getAdvancedCache().getTransactionManager();

                      logger.info("ID ?");

                      tmp1 = eingabe.next();

                     

                      tm.begin();

                      try {

                         

                          boolean tmp = cache.getAdvancedCache().lock(tmp1);

                          if (tmp) {

                              logger.info("Ausgabe: " + cache.get(tmp1));

                              tm.commit();

                          }

                          else{

                              logger.info("key is locked !");

                              tm.rollback();

                          }

                      } catch (org.infinispan.util.concurrent.TimeoutException e){

                          logger.info("Key is locked !");

                          tm.rollback();

                      }

       

       

       

       

      THIS IS THE ERROR MESSAGE

       

       

      2011-05-25 16:15:52,853 | ERROR | ,PC1-16438 | s.InvocationContextInterceptor  102 | Execution error:

      org.infinispan.util.concurrent.TimeoutException: Unable to acquire lock after [3 milliseconds] on key [1] for

      requestor [DldGlobalTransaction{coinToss=-3740216248826607882, isMarkedForRollback=false, lockIntention=1, aff

      ectedKeys=[], locksAtOrigin=[]} GlobalTransaction:<PC1-34523>:1:remote]! Lock held by [DldGlobalTransaction{co

      inToss=-5700433873888136670, isMarkedForRollback=false, lockIntention=null, affectedKeys=[1], locksAtOrigin=[]

      } GlobalTransaction:<PC1-16438>:1:local]

              at org.infinispan.container.EntryFactoryImpl.acquireLock(EntryFactoryImpl.java:228)

              at org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:155)

              at org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:107)

              at org.infinispan.interceptors.LockingInterceptor.lockKeysForLockCommand(LockingInterceptor.java:217)

              at org.infinispan.interceptors.LockingInterceptor.visitLockControlCommand(LockingInterceptor.java:195)

       

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:1

      18)

              at org.infinispan.interceptors.DeadlockDetectingInterceptor.handleDataCommand(DeadlockDetectingInterce

      ptor.java:91)

              at org.infinispan.interceptors.DeadlockDetectingInterceptor.visitLockControlCommand(DeadlockDetectingI

      nterceptor.java:73)

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:1

      18)

              at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)

              at org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:152)

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:1

      18)

              at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)

              at org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:152)

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:1

      18)

              at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:171)

              at org.infinispan.interceptors.TxInterceptor.visitLockControlCommand(TxInterceptor.java:127)

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:1

      18)

              at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)

              at org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:152)

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:1

      18)

              at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.jav

      a:95)

              at org.infinispan.interceptors.InvocationContextInterceptor.visitLockControlCommand(InvocationContextI

      nterceptor.java:67)

              at org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:146)

              at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:273)

              at org.infinispan.commands.control.LockControlCommand.perform(LockControlCommand.java:172)

              at org.infinispan.remoting.InboundInvocationHandlerImpl.handleInternal(InboundInvocationHandlerImpl.ja

      va:142)

              at org.infinispan.remoting.InboundInvocationHandlerImpl.handleWithWaitForBlocks(InboundInvocationHandl

      erImpl.java:156)

              at org.infinispan.remoting.InboundInvocationHandlerImpl.handleWithRetry(InboundInvocationHandlerImpl.j

      ava:266)

              at org.infinispan.remoting.InboundInvocationHandlerImpl.handle(InboundInvocationHandlerImpl.java:129)

              at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.executeCommand(CommandAwareRpcD

      ispatcher.java:159)

              at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatche

      r.java:144)

              at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:577)

              at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:488)

              at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:364)

              at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:770)

              at org.jgroups.JChannel.up(JChannel.java:1484)

              at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1074)

              at org.jgroups.protocols.pbcast.FLUSH.up(FLUSH.java:477)

              at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.up(STREAMING_STATE_TRANSFER.java:263)

              at org.jgroups.protocols.FRAG2.up(FRAG2.java:189)

              at org.jgroups.protocols.FlowControl.up(FlowControl.java:418)

              at org.jgroups.protocols.FlowControl.up(FlowControl.java:418)

              at org.jgroups.protocols.pbcast.GMS.up(GMS.java:891)

              at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:246)

              at org.jgroups.protocols.UNICAST.up(UNICAST.java:309)

              at org.jgroups.protocols.pbcast.NAKACK.handleMessage(NAKACK.java:805)

              at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:667)

              at org.jgroups.protocols.BARRIER.up(BARRIER.java:119)

              at org.jgroups.protocols.FD_ALL.up(FD_ALL.java:177)

              at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:275)

              at org.jgroups.protocols.MERGE2.up(MERGE2.java:209)

              at org.jgroups.protocols.Discovery.up(Discovery.java:293)

              at org.jgroups.protocols.PING.up(PING.java:69)

              at org.jgroups.protocols.TP.passMessageUp(TP.java:1109)

              at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1665)

              at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1647)

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

              at java.lang.Thread.run(Unknown Source)

      Exception in thread "main" java.util.NoSuchElementException

              at java.util.Scanner.throwFor(Unknown Source)

              at java.util.Scanner.next(Unknown Source)

              at com.lhsystems.infinispan.CacheTest.test(CacheTest.java:70)

              at com.lhsystems.infinispan.CacheStart.main(CacheStart.java:58)

       

       

      My Settings

       

      <locking lockAcquisitionTimeout="3" isolationLevel="READ_COMMITTED"

                  writeSkewCheck="false" concurrencyLevel="512" useLockStriping="false" />

       

              <!--

                  Used to register a transaction manager and participate in JTA and XA

                  transactions. See:

       

                  http://community.jboss.org/wiki/Infinispantransactions

              -->

       

              <transaction

                  transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"

                  syncRollbackPhase="false" syncCommitPhase="false" useEagerLocking="true"

                  eagerLockSingleNode="false" /> <!-- cacheStopTimeout="1000" -->

       

      <deadlockDetection enabled="true" spinDuration="100"/>