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

BatchingInterceptor is trying to resume a transaction that is in prepared state

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Minor
    • None
    • 5.1.0.FINAL
    • Core, Transactions
    • None
    • Hide

      Create a web app with Spring and Spring MVC. Add hibernate, a XA capable datasource, and JTA. You don't even need to use Hibernate through JPA. Then enable hibernate search. Use Infinispan as Hibernate second level cache, and as a Lucene Directory for Hibernate Search. Make sure Infinispan looks up for the registered transactionManager. InvocationBatching is enabled.

      Show
      Create a web app with Spring and Spring MVC. Add hibernate, a XA capable datasource, and JTA. You don't even need to use Hibernate through JPA. Then enable hibernate search. Use Infinispan as Hibernate second level cache, and as a Lucene Directory for Hibernate Search. Make sure Infinispan looks up for the registered transactionManager. InvocationBatching is enabled.

    Description

      When the Spring AppContext starts, the EntityManager bean initializes, which inits Hibernate Search, and this one inits Infinispan's Lucene Directory.
      The Directory initializes Lucene Index and closes it. In this moment, org.infinispan.batch.BatchContainer ends the batch, which was running a micro transactions, so it commits the transaction.
      The JTA sends a Prepare message to Infinispan XA. org.infinispan.interceptors.BatchingInterceptor receives the Prepare command and checks if there is an ongoing transaction. The transactionManager returns null because the transaction is not active but in prepare phase, so the BatchingInterceptor believes that the transaction is suspended and tries to resume it.

      Exception does not seem to happen if Infinispan uses JTA synchronization instead of XAresource, although in that case there is no recovery.

      Here is the stack trace:
      10:01:51,964 ERROR TransactionCoordinator:154 - Error while processing prepare
      java.lang.IllegalStateException: Transaction no longer active
      at com.atomikos.icatch.imp.TxTerminatedStateHandler.addSubTxAwareParticipant(TxTerminatedStateHandler.java:95)
      at com.atomikos.icatch.imp.CompositeTransactionImp.addSubTxAwareParticipant(CompositeTransactionImp.java:260)
      at com.atomikos.icatch.imp.BaseTransactionManager.restoreThreadMappings(BaseTransactionManager.java:168)
      at com.atomikos.icatch.imp.BaseTransactionManager.resume(BaseTransactionManager.java:393)
      at com.atomikos.icatch.jta.TransactionManagerImp.resume(TransactionManagerImp.java:399)
      at com.atomikos.icatch.jta.UserTransactionManager.resume(UserTransactionManager.java:204)
      at org.infinispan.interceptors.BatchingInterceptor.handleDefault(BatchingInterceptor.java:54)
      at org.infinispan.commands.AbstractVisitor.visitPrepareCommand(AbstractVisitor.java:113)
      at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:131)
      at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:345)
      at org.infinispan.transaction.TransactionCoordinator.prepare(TransactionCoordinator.java:140)
      at org.infinispan.transaction.TransactionCoordinator.prepare(TransactionCoordinator.java:122)
      at org.infinispan.transaction.xa.TransactionXaAdapter.commit(TransactionXaAdapter.java:122)
      at com.atomikos.datasource.xa.XAResourceTransaction.commit(XAResourceTransaction.java:784)
      at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:73)
      at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:111)
      at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:87)
      at com.atomikos.icatch.imp.Propagator.submitPropagationMessage(Propagator.java:66)
      at com.atomikos.icatch.imp.CoordinatorStateHandler.commit(CoordinatorStateHandler.java:614)
      at com.atomikos.icatch.imp.ActiveStateHandler.commit(ActiveStateHandler.java:289)
      at com.atomikos.icatch.imp.CoordinatorImp.commit(CoordinatorImp.java:863)
      at com.atomikos.icatch.imp.CoordinatorImp.terminate(CoordinatorImp.java:1157)
      at com.atomikos.icatch.imp.CompositeTerminatorImp.commit(CompositeTerminatorImp.java:92)
      at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:236)
      at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:464)
      at com.atomikos.icatch.jta.UserTransactionManager.commit(UserTransactionManager.java:175)
      at org.infinispan.batch.BatchContainer.resolveTransaction(BatchContainer.java:123)
      at org.infinispan.batch.BatchContainer.endBatch(BatchContainer.java:105)
      at org.infinispan.batch.BatchContainer.endBatch(BatchContainer.java:86)
      at org.infinispan.CacheImpl.endBatch(CacheImpl.java:577)
      at org.infinispan.lucene.InfinispanIndexOutput.close(InfinispanIndexOutput.java:211)
      at org.apache.lucene.store.ChecksumIndexOutput.close(ChecksumIndexOutput.java:61)
      at org.apache.lucene.index.SegmentInfos.finishCommit(SegmentInfos.java:901)
      at org.apache.lucene.index.IndexWriter.finishCommit(IndexWriter.java:3516)
      at org.apache.lucene.index.IndexWriter.commitInternal(IndexWriter.java:3506)
      at org.apache.lucene.index.IndexWriter.closeInternal(IndexWriter.java:1882)
      at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1825)
      at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1789)
      at org.hibernate.search.store.impl.DirectoryProviderHelper.initializeIndexIfNeeded(DirectoryProviderHelper.java:160)
      at org.hibernate.search.infinispan.impl.InfinispanDirectoryProvider.start(InfinispanDirectoryProvider.java:88)
      at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:93)
      at org.hibernate.search.indexes.impl.IndexManagerHolder.createDirectoryManager(IndexManagerHolder.java:193)
      at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:113)
      at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:373)
      at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:224)
      at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:142)
      at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:129)
      at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:82)
      at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
      at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:257)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:530)
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
      at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4521)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5004)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:4999)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      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:680)

      Attachments

        Activity

          People

            mircea.markus Mircea Markus (Inactive)
            sqquima Luciano Leggieri (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: