You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/01/10 10:45:00 UTC

[jira] [Work logged] (ARTEMIS-2144) tx begin failure in ra doesn't get cleaned up

     [ https://issues.apache.org/jira/browse/ARTEMIS-2144?focusedWorklogId=183647&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-183647 ]

ASF GitHub Bot logged work on ARTEMIS-2144:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Jan/19 10:44
            Start Date: 10/Jan/19 10:44
    Worklog Time Spent: 10m 
      Work Description: andytaylor commented on pull request #2495: ARTEMIS-2144 - fixing brokern test
URL: https://github.com/apache/activemq-artemis/pull/2495
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 183647)
            Time Spent: 10m
    Remaining Estimate: 0h

> tx begin failure in ra doesn't get cleaned up
> ---------------------------------------------
>
>                 Key: ARTEMIS-2144
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2144
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 1.5.5, 2.6.3
>            Reporter: Jonathan Halliday
>            Assignee: Andy Taylor
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.onMessage calls to endpoint.beforeDelivery(ActiveMQActivation.ONMESSAGE) (i.e. Spring framework) to begin a Transaction (associating it to the Thread) and enlist the XAResource to that Transaction. These operations may fail independently:
> {code:java}
> // AbstractMessageEndpointFactory.java
> public void beginTransaction() throws Exception {
>   if (transactionFactory != null && this.xaResource != null) {
>     // This line works, associating the tx to the Thread, because that's a local operation.
>     this.transaction = transactionFactory.createTransaction(transactionName, transactionTimeout);
>     // This line fails, because it's a remote call to a dead MQ server
>     this.transaction.enlistResource(this.xaResource);
>   }
> }
> {code}
> {code:java}
> # example trace (wildfly application server, artemis 1.5.5)
> ERROR [org.apache.activemq.artemis.ra] (Thread-40 (ActiveMQ-client-global-threads)) AMQ154004: Failed to deliver message: javax.resource.spi.ApplicationServerInternalException: Failed to begin transaction
>  at org.springframework.jca.endpoint.AbstractMessageEndpointFactory$AbstractMessageEndpoint.beforeDelivery(AbstractMessageEndpointFactory.java:221) at org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.onMessage(ActiveMQMessageHandler.java:293)
>  at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1001)
>  at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:49)
>  at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1124)
>  at org.apache.activemq.artemis.utils.OrderedExecutorFactory$OrderedExecutor$ExecutorTask.run(OrderedExecutorFactory.java:122)
>  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  at java.lang.Thread.run(Thread.java:745)
> Caused by: javax.transaction.SystemException: WFTXN0089: Failed to configure transaction timeout of 299
>  at org.wildfly.transaction.client.LocalTransaction.enlistResource(LocalTransaction.java:155)
>  at org.springframework.transaction.jta.ManagedTransactionAdapter.enlistResource(ManagedTransactionAdapter.java:83)
>  at org.springframework.jca.endpoint.AbstractMessageEndpointFactory$TransactionDelegate.beginTransaction(AbstractMessageEndpointFactory.java:313)
>  at org.springframework.jca.endpoint.AbstractMessageEndpointFactory$AbstractMessageEndpoint.beforeDelivery(AbstractMessageEndpointFactory.java:218)
>  ... 8 more
> {code}
> In such case, it is necessary that ActiveMQMessageHandler ensure termination of the transaction before returning control. This can be accomplished by e.g.
> |{code:java}
> try {
>    endpoint.beforeDelivery(ActiveMQActivation.ONMESSAGE);
> } catch(ApplicationServerInternalException asie) {
>    Throwable cause = asie.getCause();
>    if(cause instanceof SystemException) {
>       if(tm != null &&  tm.getStatus() != Status.STATUS_NO_TRANSACTION) {
>          ActiveMQRALogger.LOGGER.trace("HornetQMessageHandler::tx begin failed uncleanly with "+cause.getMessage()+". Trying to clean up.");
>          tm.setRollbackOnly();
>          endpoint.afterDelivery();
>       }
>    }
>    throw asie;
> }
> {code}|
> Failure to include this cleanup step results in the broken Transaction remaining associated to the Thread, which thereafter cannot be reused in a pooled environment.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)