5 Replies Latest reply on Jan 18, 2010 8:27 AM by Galder Zamarreño

    ClearCommand participates on global transaction and produces a lock! Is this wanted behavoiur or a bug?

    Guenther Demetz Newbie

      Hi,

       

      I use Infinispan as 2L-cache implementation for Hibernate.

      I assumed that general evict actions are handled as atomic actions even if being in transaction (transactionmanager.getStatus == Status.STATUS_ACTIVE).

      Indeed such actions (for instance sessionfactory.getCache.evictEntityRegion(Apersistent.class)) do participate on the global transaction,

      and produce a lock which is hold until the transaction ends.

       

      userTransaction.begin();

      sessionfactory.getCache.evictEntityRegion(A.class); // action participates on global transaction and produces a lock

      TransactionManager().suspend(); // suspend current global transaction

      sessionfactory.getCache.evictEntityRegion(A.class); // this action fails as it goes in timeout after 15 seconds

      org.infinispan.util.concurrent.TimeoutException: Unable to acquire lock after [15 seconds] on key [hello.A#1] for requestor [Thread[main,5,main]]! Lock held by [GlobalTransaction:<localhost-8797>:3]
          at org.infinispan.factories.EntryFactoryImpl.acquireLock(EntryFactoryImpl.java:198)
          at org.infinispan.factories.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:143)
          at org.infinispan.interceptors.LockingInterceptor.visitClearCommand(LockingInterceptor.java:167)
          at org.infinispan.commands.write.ClearCommand.acceptVisitor(ClearCommand.java:55)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.InvalidationInterceptor.visitClearCommand(InvalidationInterceptor.java:108)
          at org.infinispan.commands.write.ClearCommand.acceptVisitor(ClearCommand.java:55)
          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.visitClearCommand(AbstractVisitor.java:69)
          at org.infinispan.commands.write.ClearCommand.acceptVisitor(ClearCommand.java:55)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:179)
          at org.infinispan.interceptors.TxInterceptor.visitClearCommand(TxInterceptor.java:141)
          at org.infinispan.commands.write.ClearCommand.acceptVisitor(ClearCommand.java:55)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:48)
          at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:34)
          at org.infinispan.commands.AbstractVisitor.visitClearCommand(AbstractVisitor.java:69)
          at org.infinispan.commands.write.ClearCommand.acceptVisitor(ClearCommand.java:55)
          at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:256)
          at org.infinispan.CacheDelegate.clear(CacheDelegate.java:369)
          at org.infinispan.CacheDelegate.clear(CacheDelegate.java:188)
          at org.hibernate.cache.infinispan.access.TransactionalAccessDelegate.evictOrRemoveAll(TransactionalAccessDelegate.java:110)
          at org.hibernate.cache.infinispan.access.TransactionalAccessDelegate.evictAll(TransactionalAccessDelegate.java:106)
          at org.hibernate.cache.infinispan.entity.TransactionalAccess.evictAll(TransactionalAccess.java:32)
          at org.hibernate.impl.SessionFactoryImpl$CacheImpl.evictEntityRegion(SessionFactoryImpl.java:1004)
          at org.hibernate.impl.SessionFactoryImpl$CacheImpl.evictEntityRegion(SessionFactoryImpl.java:995)

       

       

      Please consider attached testcase.. (run: java JTAStandaloneExampleJBossTM)