These days to do transaction recover test, found a difficult to understand the problem.
The specific problem scenario is as follows:
1: A standby client program that calls Usertransaction.begin () and then operates in sequence two XA resource, two resource for the same Oracle database, However, the operation uses connection from different data source. Connection1 inserts a piece of data into the table test, Connection2 inserts a piece of data into the table test1. The final execution of Usertransaction.commit ().
When 2:usertransaction.commit () executes, a two-phase commit is required, first the global prepare, and if all resource are prepare OK, WebLogic writes the TX record ( Written to TLog). Then execute the global commit. During the test, after the global prepare is executed, set the break point at the global commit and stop the database. When the database is stopped, the break point of the global commit is removed, and WebLogic needs to issue a commit to each resource. Because some resource are unavailable at this time, WebLogic cannot receive a response from each resource commit, which is kept in TLog until the server is reset recover.
3: In accordance with the normal logic of the global prepare completion, the TX should be only commit, but not rollback, but found in the test, WebLogic in recover, will go rollback this TX.
The following is the data information that is recorded in the test.
1: After the database is WebLogic, you can see that the TX information in the DB is as follows:
The information in the 2:weblogic TLog,
+------------------------------------------------------------------------------+
| Transaction Log Dump | |
+------------------------------------------------------------------------------+
| Class Name = weblogic.transaction.internal.ResourceCheckpoint |
| Object = ResourceCheckpoint={OracelXADS, OracleXADS1} |
+------------------------------------------------------------------------------+