您的位置:首页 > 数据库 > Oracle

Oracle WebLogic Server: How to clear pending XA transactions(Oracle Thin/XA Driver)?

2015-01-29 17:58 429 查看
If you are using XA transactions in your JDBC
datasource and you are using Oracle Thin/XA Driver, and you have errors, for example:
java.sql.SQLException: Internal error: Cannot obtain XAConnection weblogic.common.resourcepool.ResourceDeadException: Pool testJDBCDataSource is disabled, cannot allocate resources to applications.

Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XAER_RMERR start() failed on resource 'testJDBCDataSource': XAER_RMERR : A resource manager error has occured in the transaction branch  oracle.jdbc.xa.OracleXAException

Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XAER_RMERR start() failed on resource 'testJDBCDataSource': XAER_RMERR : A resource manager error has occured in the transaction branchoracle.jdbc.xa.OracleXAException


When the Weblogic Server unclean pending XA
transactions. How It fix?

First you need to enable XA in the database:
Log on to database as system user
Execute sql script xaview.sql in ORACLE_HOME/rdbms/admin
Execute sql:
grant select on v$xatrans$ to public (or <user>);


 Execute sql:
grant select on pending_trans$ to public;


Execute sql:
grant select on dba_2pc_pending to public;


Here are the details.
Any database account performing distributed transactions must have the following privileges:

Execute sql:
grant select on dba_pending_transactions to public;


Execute sql:
grant force any transaction to public (or <user>);


Second, you need to enable cleaning unfinished/pending transactions in WebLogic Server.
Enable Recover Only Once for the JDBC data source.
Enable XA End Only Once for the JDBC data source.



Why enable “Recover Only Once”?

The WebLogic Server transaction manager retries the commit call every minute, until a valid XAResource instance is registered with the WebLogic Server transaction manager, if the setting “Recover only once” is allowed and the commit call failure then the Weblogic
Server transaction manager calls recover on the resource only once and not every minute.

More information about the recovery are here.

How to select pending XA transaction in DB?
select count(*) , min(fail_time),max(fail_time) from dba_2pc_pending;

转载自:http://www.tomecode.com/2010/10/30/oracle-weblogic-server-how-to-clear-pending-xa-transactionsoracle-thinxa-driver/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: