Description
I've noticed issues with distributed transactions (XA) on karaf when using ActiveMQ with JDBC storeage (postgres). After some time (it isn't deterministic) I've observed that on database side 'idle in transaction' appeared (it's other schema than used by ActiveMQ). After debugging it seams that the reason why transactions are hanging is ActiveMQ and org.apache.activemq.transport.FutureResponse.getResult method that waits forever for a response.
java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x0000000768585aa8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403) at org.apache.activemq.transport.FutureResponse.getResult(FutureResponse.java:48) at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:87) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1388) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1428) at org.apache.activemq.TransactionContext.setXid(TransactionContext.java:751) at org.apache.activemq.TransactionContext.invokeBeforeEnd(TransactionContext.java:424) at org.apache.activemq.TransactionContext.end(TransactionContext.java:408) at org.apache.geronimo.transaction.manager.WrapperNamedXAResource.end(WrapperNamedXAResource.java:61) at org.apache.geronimo.transaction.manager.TransactionImpl.endResources(TransactionImpl.java:588) at org.apache.geronimo.transaction.manager.TransactionImpl.endResources(TransactionImpl.java:567) at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:414) at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:262) at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:252) at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1020) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.apache.aries.transaction.internal.AriesPlatformTransactionManager.commit(AriesPlatformTransactionManager.java:75) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:484) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ..... custom service
"DefaultMessageListenerContainer-3" #13199 prio=5 os_prio=0 tid=0x00007fb8687e6800 nid=0x3954 waiting on condition [0x00007fb7b0b98000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x0000000765f532c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403) at org.apache.activemq.transport.FutureResponse.getResult(FutureResponse.java:48) at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:87) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1388) at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1428) at org.apache.activemq.TransactionContext.setXid(TransactionContext.java:751) at org.apache.activemq.TransactionContext.invokeBeforeEnd(TransactionContext.java:424) at org.apache.activemq.TransactionContext.end(TransactionContext.java:408) at org.apache.geronimo.transaction.manager.WrapperNamedXAResource.end(WrapperNamedXAResource.java:61) at org.apache.geronimo.transaction.manager.TransactionImpl.endResources(TransactionImpl.java:588) at org.apache.geronimo.transaction.manager.TransactionImpl.endResources(TransactionImpl.java:567) at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:414) at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:262) at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:252) at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1020) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.apache.aries.transaction.internal.AriesPlatformTransactionManager.commit(AriesPlatformTransactionManager.java:75) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:245) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1164) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1156) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1053) at java.lang.Thread.run(Thread.java:748)