Description
Under abnormal conditions, some of our JMS listeners use longer than expected time. The listeners are using XA transactions. If a XA transaction timer is triggered, eventhough the listener successfully processed the message, we get an NPE and jdbc connection leak in the broker.
The offending stack is:
2020-05-06 14:01:51,697 [eListenerContainer-1] WARN .x.XAResourceTransaction - XA resource 'xamq': rollback for XID '3139322E3136382E322E3134302E746D313538383739383839393936303030303036:3139322E3136382E322E3134302E746D36' raised -7: the XA resource has become unavailable
javax.transaction.xa.XAException: java.lang.NullPointerException
at org.apache.activemq.TransactionContext.toXAException(TransactionContext.java:803) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.TransactionContext.rollback(TransactionContext.java:552) ~[activemq-client-5.15.12.jar:5.15.12]
at com.atomikos.datasource.xa.XAResourceTransaction.rollback(XAResourceTransaction.java:460) [transactions-jta-4.0.6.jar:?]
at com.atomikos.icatch.imp.RollbackMessage.send(RollbackMessage.java:47) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.RollbackMessage.send(RollbackMessage.java:20) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:67) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:63) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.Propagator.submitPropagationMessage(Propagator.java:42) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.CoordinatorStateHandler.rollbackFromWithinCallback(CoordinatorStateHandler.java:468) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.ActiveStateHandler$4.doRollback(ActiveStateHandler.java:189) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.CoordinatorStateHandler.rollbackWithAfterCompletionNotification(CoordinatorStateHandler.java:563) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.ActiveStateHandler.prepare(ActiveStateHandler.java:184) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.CoordinatorImp.prepare(CoordinatorImp.java:523) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.CoordinatorImp.terminate(CoordinatorImp.java:687) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.imp.CompositeTransactionImp.commit(CompositeTransactionImp.java:282) [transactions-4.0.6.jar:?]
at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:172) [transactions-jta-4.0.6.jar:?]
at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:414) [transactions-jta-4.0.6.jar:?]
at com.atomikos.icatch.jta.UserTransactionImp.commit(UserTransactionImp.java:86) [transactions-jta-4.0.6.jar:?]
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1035) [spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743) [spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) [spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:251) [spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1189) [spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179) [spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076) [spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: javax.jms.JMSException: java.lang.NullPointerException
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1403) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1436) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.TransactionContext.rollback(TransactionContext.java:538) ~[activemq-client-5.15.12.jar:5.15.12]
... 24 more
Caused by: java.lang.NullPointerException
at org.apache.activemq.store.jdbc.JdbcMemoryTransactionStore.rollback(JdbcMemoryTransactionStore.java:181) ~[activemq-jdbc-store-5.15.12.jar:5.15.12]
at org.apache.activemq.transaction.XATransaction.rollback(XATransaction.java:146) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.broker.TransactionBroker.rollbackTransaction(TransactionBroker.java:257) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.broker.BrokerFilter.rollbackTransaction(BrokerFilter.java:149) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.broker.BrokerFilter.rollbackTransaction(BrokerFilter.java:149) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.broker.TransportConnection.processRollbackTransaction(TransportConnection.java:553) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.command.TransactionInfo.visit(TransactionInfo.java:104) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:336) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:200) ~[activemq-broker-5.15.12.jar:5.15.12]
at org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:125) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:301) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233) ~[activemq-client-5.15.12.jar:5.15.12]
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215) ~[activemq-client-5.15.12.jar:5.15.12]
at java.lang.Thread.run(Thread.java:834) ~[?:?]
It is believed that this might be related to, or have same underlying root condition as AMQ-7424