We're encountering a situation where we're encountering a deadlock, and
someone's been made the deadlock victim. But after that, DB2 refuses to run
any SQL, and instead we get the error message:
"Application must execute a rollback. The unit of work has already been
rolled back in the database but other resource managers involved in this
unit of work might not. To ensure integrity of this application, all SQL
requests will be rejected until the application issues a rollback."
What's odd is that we do issue a rollback, but DB2 then throws an error
saying that there is no transaction in progress. So the question is: If we
must issue a rollback, but when we do we get a warning, how do we issue a
rollback without issuing a rollback.
Here's the detailed pseudo-code sequence of events:
Start a transaction
try {
Open a connection to the database
try {
Execute an INSERT statement
}
catch {
Caught the following exception:
DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 68
Execute a ROLLBACK; which triggered another exception:
"An exception occurred while invoking rollback on an XA Resource
Adapter from dataSource jdbc/OLGCSURV, within transaction ID {XID:
formatId(57415344), gtrid_length(29), bqual_length(25), data(00000001
E0280D0D 145270CB 48E5DF26 D2DCFB89 374466CC F99E946C F9015270 CB48E5DF
26D2DCFB 89374466 CCF99E94 6CF9BAE4 0073)}: com.ibm.db2.jcc.a.bh: XAER_NOTA"
}
}
finally {
Before closing the connection to the database, run a stored procedure to
do some required cleanup. This triggered another exception:
"Application must execute a rollback. The unit of work has already been
rolled back in the database but other resource managers involved in this
unit of work might not. To ensure integrity of this application, all SQL
requests will be rejected until the application issues a rollback. "
}
Why are we getting an error when we issue the required rollback. And how do
we issue a rollback without issuing a rollback? What can we do differently?
How can we break the database connection out of the state where it thinks
the application needs to execute a rollback?