0

好的,一个看似简单的两阶段提交实现遇到了问题。我的设置是一个 DB2 服务器上的 2 个数据库,一个托管在 Websphere 6.1 上的应用程序。由 Atomikos 处理的事务管理。通过 jndi 连接数据库。我开始 UserTransaction,在 DB1 上执行更新,在更新到 DB2 时失去与 DB 的连接以获得调用回滚的StaleConnectionException 。现在理想情况下,TM 应该为事务执行回滚。但是,我得到一个 XAException 如下:

[3/22/12 11:52:21:022 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_0.txt

[3/22/12 11:52:21:053 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_0.txt
[3/22/12 11:52:21:053 EDT] 00000023 WSRdbXaResour E   DSRA0304E:  XAException occurred. XAException contents and details are: 
The DB2 Error message is : [jcc][t4][10335][11391][3.53.70] Invalid operation: Connection is closed. ERRORCODE=-4470, SQLSTATE=08003
The DB2 Error code is    : -4470
The DB2 SQLState is      : 08003
.
[3/22/12 11:52:21:053 EDT] 00000023 WSRdbXaResour E   DSRA0302E:  XAException occurred.  Error code is: XAER_RMFAIL (-7).  Exception is: [jcc][t4][10401][12066][3.53.70] XA exception: XAER_RMFAIL : [jcc][t4][10335][11391][3.53.70] Invalid operation: Connection is closed. ERRORCODE=-4470, SQLSTATE=08003 ERRORCODE=-4228, SQLSTATE=null
[3/22/12 11:52:21:085 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_1.txt
[3/22/12 11:52:21:100 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_1.txt
[3/22/12 11:52:21:116 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_2.txt
[3/22/12 11:52:21:163 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_2.txt
[3/22/12 11:52:21:194 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_3.txt
[3/22/12 11:52:21:225 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_3.txt
[3/22/12 11:52:21:256 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_4.txt
[3/22/12 11:52:21:288 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_4.txt
[3/22/12 11:52:21:288 EDT] 00000023 WSRdbXaResour E   DSRA0304E:  XAException occurred. XAException contents and details are: 
The DB2 Error message is : [jcc][t4][2030][11211][3.53.70] A communication error occurred during operations on the connection's underlying socket, socket input stream, 
or socket output stream.  Error location: T4Agent.sendRequest().  Message: Connection reset by peer: socket write error. ERRORCODE=-4499, SQLSTATE=08001
The DB2 Error code is    : -4499
The DB2 SQLState is      : 08001
.
[3/22/12 11:52:21:288 EDT] 00000023 WSRdbXaResour E   DSRA0302E:  XAException occurred.  Error code is: XA_RETRY (4).  Exception is: [jcc][t4][10401][12066][3.53.70] XA exception: XA_RETRY : [jcc][t4][2030][11211][3.53.70] A communication error occurred during operations on the connection's underlying socket, socket input stream, 
or socket output stream.  Error location: T4Agent.sendRequest().  Message: Connection reset by peer: socket write error. ERRORCODE=-4499, SQLSTATE=08001 ERRORCODE=-4228, SQLSTATE=null
[3/22/12 11:52:21:288 EDT] 00000023 ConnectionEve A   J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adapter for resource jdbc/myDatasource1.  The exception which was received is com.ibm.db2.jcc.b.po: [jcc][t4][10401][12066][3.53.70] XA exception: XA_RETRY : [jcc][t4][2030][11211][3.53.70] A communication error occurred during operations on the connection's underlying socket, socket input stream, 
or socket output stream.  Error location: T4Agent.sendRequest().  Message: Connection reset by peer: socket write error. ERRORCODE=-4499, SQLSTATE=08001 ERRORCODE=-4228, SQLSTATE=null:com.ibm.db2.jcc.b.tn: [jcc][t4][2030][11211][3.53.70] A communication error occurred during operations on the connection's underlying socket, socket input stream, 
or socket output stream.  Error location: T4Agent.sendRequest().  Message: Connection reset by peer: socket write error. ERRORCODE=-4499, SQLSTATE=08001:java.net.SocketException: Connection reset by peer: socket write error
[3/22/12 11:52:21:319 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_5.txt
[3/22/12 11:52:21:335 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_5.txt
[3/22/12 11:52:21:350 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_6.txt
[3/22/12 11:52:21:397 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_6.txt
[3/22/12 11:52:21:413 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_7.txt
[3/22/12 11:52:21:444 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_7.txt
[3/22/12 11:52:21:522 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl open FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_8.txt
[3/22/12 11:52:21:553 EDT] 00000023 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\SDP\runtimes\base_v61\profiles\was61profile1\logs\ffdc\server1_00000023_12.03.22_11.52.21_8.txt
[3/22/12 11:53:16:804 EDT] 00000023 SystemOut     O Transaction Failed
[3/22/12 11:53:21:522 EDT] 0000000f InternalDB2Un I   DSRA8203I: Database product name : DB2/NT
[3/22/12 11:53:21:522 EDT] 0000000f InternalDB2Un I   DSRA8204I: Database product version : SQL09056
[3/22/12 11:53:21:522 EDT] 0000000f InternalDB2Un I   DSRA8205I: JDBC driver name  : IBM DB2 JDBC Universal Driver Architecture
[3/22/12 11:53:21:522 EDT] 0000000f InternalDB2Un I   DSRA8206I: JDBC driver version  : 3.53.70
[3/22/12 11:53:21:522 EDT] 0000000f InternalDB2Un I   DSRA8212I: DataStoreHelper name is: com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper@150a150a.
[3/22/12 11:53:21:522 EDT] 0000000f WSRdbDataSour I   DSRA8208I: JDBC driver type  : 4
[3/22/12 11:53:21:585 EDT] 0000000f WSRdbXaResour E   DSRA0304E:  XAException occurred. XAException contents and details are: "".
[3/22/12 11:53:21:585 EDT] 0000000f WSRdbXaResour E   DSRA0302E:  XAException occurred.  Error code is: XAER_NOTA (-4).  Exception is: [jcc][t4][10401][12066][3.53.70] XA exception: XAER_NOTA ERRORCODE=-4228, SQLSTATE=null

在此之后执行更新的 DB1 表被锁定。到目前为止,我已经尝试了以下方法,但仍然无法执行回滚:

  1. 查询正在使用未提交的读取('ur')
  2. 连接自动提交设置为 false,IsolationLevel 设置为 *TRANSACTION_READ_UNCOMMITTED*
  3. 增加了数据源和事务服务的各种超时值。
  4. 连接池最小连接数设置为 0,清除策略:EntirePool
  5. 正在捕获StaleConnectionException并从 catch 块调用 UserTransaction.rollback()。

如何使用两阶段提交和 XAtransactions 从数据库崩溃中恢复?任何指向应该为此做些什么的指针?

4

0 回答 0