You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Alexei Akimov (JIRA)" <ji...@apache.org> on 2011/08/23 14:53:29 UTC

[jira] [Created] (AMQ-3465) TransactionContext produces errors in concurrent environment

TransactionContext produces errors in concurrent environment
------------------------------------------------------------

                 Key: AMQ-3465
                 URL: https://issues.apache.org/jira/browse/AMQ-3465
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker
    Affects Versions: 5.5.0
         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
            Reporter: Alexei Akimov


Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:

public boolean isInXATransaction() {
    return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
}

Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (AMQ-3465) TransactionContext produces errors in concurrent environment

Posted by "Timothy Bish (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQ-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish resolved AMQ-3465.
-------------------------------

    Resolution: Fixed

Fix applied in trunk.
                
> TransactionContext produces errors in concurrent environment
> ------------------------------------------------------------
>
>                 Key: AMQ-3465
>                 URL: https://issues.apache.org/jira/browse/AMQ-3465
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.0
>         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
>            Reporter: Alexei Akimov
>            Assignee: Timothy Bish
>             Fix For: 5.6.0
>
>
> Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:
> public boolean isInXATransaction() {
>     return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
> }
> Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (AMQ-3465) TransactionContext produces errors in concurrent environment

Posted by "Timothy Bish (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQ-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish reassigned AMQ-3465:
---------------------------------

    Assignee: Timothy Bish
    
> TransactionContext produces errors in concurrent environment
> ------------------------------------------------------------
>
>                 Key: AMQ-3465
>                 URL: https://issues.apache.org/jira/browse/AMQ-3465
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.0
>         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
>            Reporter: Alexei Akimov
>            Assignee: Timothy Bish
>             Fix For: 5.6.0
>
>
> Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:
> public boolean isInXATransaction() {
>     return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
> }
> Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Reopened] (AMQ-3465) TransactionContext produces errors in concurrent environment

Posted by "Alexei Akimov (Reopened) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQ-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Akimov reopened AMQ-3465:
--------------------------------


The patch, provided by Timothy Bish, seems to be incorrect. Here is declaration of ENDED_XA_TRANSACTION_CONTEXTS:

private final static ConcurrentHashMap<TransactionId, List<TransactionContext>> ENDED_XA_TRANSACTION_CONTEXTS = ...

So the type of map values is List<TransactionContext>. And here is the patched code:

public boolean isInXATransaction() {
    return (transactionId != null && transactionId.isXATransaction()) || (!ENDED_XA_TRANSACTION_CONTEXTS.isEmpty() && ENDED_XA_TRANSACTION_CONTEXTS.containsValue(this));
}

It is clear, the last condition ENDED_XA_TRANSACTION_CONTEXTS.containsValue(this) never holds just because the map contains lists of TransactionContext but not Transaction context itself.
                
> TransactionContext produces errors in concurrent environment
> ------------------------------------------------------------
>
>                 Key: AMQ-3465
>                 URL: https://issues.apache.org/jira/browse/AMQ-3465
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.0
>         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
>            Reporter: Alexei Akimov
>            Assignee: Timothy Bish
>             Fix For: 5.6.0
>
>
> Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:
> public boolean isInXATransaction() {
>     return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
> }
> Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (AMQ-3465) TransactionContext produces errors in concurrent environment

Posted by "William Youmans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQ-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13105051#comment-13105051 ] 

William Youmans commented on AMQ-3465:
--------------------------------------

I am experiencing similar issue as described in this JIRA bug report and in the nabble link.

> TransactionContext produces errors in concurrent environment
> ------------------------------------------------------------
>
>                 Key: AMQ-3465
>                 URL: https://issues.apache.org/jira/browse/AMQ-3465
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.0
>         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
>            Reporter: Alexei Akimov
>
> Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:
> public boolean isInXATransaction() {
>     return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
> }
> Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (AMQ-3465) TransactionContext produces errors in concurrent environment

Posted by "Timothy Bish (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQ-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish resolved AMQ-3465.
-------------------------------

    Resolution: Fixed

Fix and new unit test added to trunk.
                
> TransactionContext produces errors in concurrent environment
> ------------------------------------------------------------
>
>                 Key: AMQ-3465
>                 URL: https://issues.apache.org/jira/browse/AMQ-3465
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.0
>         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
>            Reporter: Alexei Akimov
>            Assignee: Timothy Bish
>             Fix For: 5.6.0
>
>
> Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:
> public boolean isInXATransaction() {
>     return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
> }
> Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (AMQ-3465) TransactionContext produces errors in concurrent environment

Posted by "Timothy Bish (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQ-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish updated AMQ-3465:
------------------------------

    Fix Version/s: 5.6.0
    
> TransactionContext produces errors in concurrent environment
> ------------------------------------------------------------
>
>                 Key: AMQ-3465
>                 URL: https://issues.apache.org/jira/browse/AMQ-3465
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.5.0
>         Environment: Windows XP SP2, Oracle JDK 1.6.0_23
>            Reporter: Alexei Akimov
>            Assignee: Timothy Bish
>             Fix For: 5.6.0
>
>
> Method "isInXATransaction" of class org.apache.activemq.TransactionContext seems to be implemeted incorrectly. Here is the code:
> public boolean isInXATransaction() {
>     return (transactionId != null && transactionId.isXATransaction()) || !ENDED_XA_TRANSACTION_CONTEXTS.isEmpty();
> }
> Map "ENDED_XA_TRANSACTION_CONTEXTS" is a static field. TransactionContext instances are used for both outbound and inbound communications. Suppose a thread creating a new non-transactional session. It calls isInXATransaction and gets true, just because another thread is completing transactional message delivery at the same time. After XAResource.end() call but before XAResource.commit() call the map is not empty and it results in a JMSException in the first thread (see org.apache.activemq.ra.ManagedTransactionContext.setUseSharedTxContext(boolean)").

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira