Resending because I did not see this appear on the list probably because I sent
from my home account.
—
While coming up with a fix for
I see this code in XATransactionState.java:
/**
* This function is called from the timer task when the transaction
* times out.
*
* @see CancelXATransactionTask
*/
synchronized void cancel(String messageId) throws XAException {
// Check performTimeoutRollback just to be sure that
// the cancellation task was not started
// just before the xa_commit/rollback
// obtained this object's monitor.
if (performTimeoutRollback) {
// Log the message about the transaction cancelled
if (messageId != null)
Monitor.logTextMessage(messageId, xid.toString());
// Check whether the transaction is associated
// with any EmbedXAResource instance.
if (associationState == XATransactionState.T1_ASSOCIATED) {
conn.cancelRunningStatement();
EmbedXAResource assocRes = associatedResource;
end(assocRes, XAResource.TMFAIL, true);
}
// Rollback the global transaction
try {
conn.xa_rollback();
} catch (SQLException sqle) {
XAException ex = new XAException(XAException.XAER_RMERR);
ex.initCause(sqle);
throw ex;
}
// Do the cleanup on the resource
creatingResource.returnConnectionToResource(this, xid);
}
}
So the actually operation of the cancel is only going to be called if
“performTimeoutRollback” is true. This attribute is package private and is
only ever set to true by
/**
* Schedule a timeout task which will rollback the global transaction
* after the specified time will elapse.
*
* @param timeoutMillis The number of milliseconds to be elapsed before
* the transaction will be rolled back.
*/
synchronized void scheduleTimeoutTask(long timeoutMillis) {
// Mark the transaction to be rolled back bby timeout
performTimeoutRollback = true;
// schedule a time out task if the timeout was specified
if (timeoutMillis > 0) {
// take care of the transaction timeout
timeoutTask = new CancelXATransactionTask(this);
getTimerFactory().schedule(timeoutTask, timeoutMillis);
} else {
timeoutTask = null;
}
}
which is the timer task to cancel a XA transaction when the timeout expires.
We also have “cancel” above being called by
/** @see
org.apache.derby.iapi.jdbc.ResourceAdapter#cancelXATransaction(XAXactId, String)
*/
public void cancelXATransaction(XAXactId xid, String messageId)
throws XAException
{
XATransactionState xaState = (XATransactionState)
findConnection(xid);
if (xaState != null) {
xaState.cancel(messageId);
}
}
in ResourceAdapterImpl.java and that can be called by
DRDAXAProtocol.rollbackCurrentTransaction which is called by
DRDAConnThread.closeSession which itself is called when there is an exception
or error.
None of those called will ever have “performTimeoutRollback” set to “true” so
effectively they are doing nothing. That is how I understand this.
In particular in DRDAConnectionThread.run we have:
} catch (Exception e) {
if (e instanceof DRDAProtocolException &&
((DRDAProtocolException)e).isDisconnectException())
{
// client went away - this is O.K. here
closeSession();
}
else
{
handleException(e);
}
} catch (Error error) {
So it appears that if a network client were to start a XA transaction and then
get disconnected, the probably this code would be called. The “closeSession”
would be called which would call DRDAXAProtocol.rollbackCurrentTransaction
which would call ResourceAdapterImpl.cancelXATransaction which as I show above
called XATransactionState.cancel which will have “performTimeoutRollback”
having a value of “false” and as such, the XA transaction will not be rolled
back.
I don’t know the XA specification well enough but do think that this might be
an issue.
Canoga Perkins
20600 Prairie Street
Chatsworth, CA 91311
(818) 718-6300
This e-mail and any attached document(s) is confidential and is intended only
for the review of the party to whom it is addressed. If you have received this
transmission in error, please notify the sender immediately and discard the
original message and any attachment(s).