Distributed Transactions and Timeouts

来源:互联网 发布:制造业大数据解决方案 编辑:程序博客网 时间:2024/05/22 00:09
We're using JTA distributed transactions (across WebLogic 8.1 and Oracle), and we noticed that the following exception occasionally was causing us errors:
java.sql.SQLException: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAER_NOTA : The XID is not valid start() failed on resource '[connection pool]': XAER_NOTA : The XID is not valid oracle.jdbc.xa.OracleXAException at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1017) at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:227) at weblogic.jdbc.wrapper.VendorXAResource.start(VendorXAResource.java:50)

Turns out that Oracle was timing out the transaction on its side of things.  Here's ageneral description of the problem:
A general rule to follow is to make sure that WebLogic Server JTA timeout (either global, specific to an EJB or for individual transactions) is set to a lower value than the shortest timeout value configured/set for a participating XA resource (e.g., XA Transaction Timeout for Oracle XA JDBC connections). Not doing so can lead to an unexpected and inconsistent distributed transaction outcome, i.e., a participating XA Resource timing out before WebLogic Server JTA as the distributed transaction coordinator. The timed out XA Resource may take action to resolve its own part of the distributed transaction before WebLogic Server can take action. This will lead to heuristic error messages at the time when the WebLogic transaction manager tries to prepare/commit the distributed transaction.

The solution was that for the JDBC Connection Pools to set the XASetTransactionTimeout to true andXATransactionTimeout to zero ("When this parameter is set to zero, the XAResource Session Timeout will be set to the global transaction timeout.")

Hope this post helps save some people the hassle we went through to figure this out...