Skip to content
Permalink
Browse files
GERONIMO-4478 enhance exception handling during transaction rollback …
…+ some message updates

git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@728724 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Lin Sun committed Dec 22, 2008
1 parent 9c83587 commit 02fc9bc4273322b4acb9d7febe41832c8bf44704
Showing 1 changed file with 25 additions and 17 deletions.
@@ -262,12 +262,12 @@ public void commit() throws HeuristicMixedException, HeuristicRollbackException,
if (TransactionTimer.getCurrentTime() > timeout) {
status = Status.STATUS_MARKED_ROLLBACK;
timedout = true;
}
}

if (status == Status.STATUS_MARKED_ROLLBACK) {
rollbackResourcesDuringCommit(resourceManagers, false);
if (timedout) {
throw new RollbackException("Transaction timeout");
throw new RollbackException("Unable to commit: Transaction timeout");
} else {
throw new RollbackException("Unable to commit: transaction marked for rollback");
}
@@ -596,17 +596,25 @@ private void rollbackResources(List rms) throws SystemException {
synchronized (this) {
status = Status.STATUS_ROLLING_BACK;
}
for (Iterator i = rms.iterator(); i.hasNext();) {
TransactionBranch manager = (TransactionBranch) i.next();
try {
manager.getCommitter().rollback(manager.getBranchId());
} catch (XAException e) {
log.error("Unexpected exception rolling back " + manager.getCommitter() + "; continuing with rollback", e);
if (cause == null) {
cause = new SystemException(e.errorCode);
try {
for (Iterator i = rms.iterator(); i.hasNext();) {
TransactionBranch manager = (TransactionBranch) i.next();
try {
manager.getCommitter().rollback(manager.getBranchId());
} catch (XAException e) {
log.error("Unexpected exception rolling back " + manager.getCommitter() + "; continuing with rollback", e);
if (e.errorCode == XAException.XA_HEURRB) {
// let's not set the cause here
log.info("Transaction has been heuristically rolled back " + manager.getCommitter() + "; continuing with rollback", e);
manager.getCommitter().forget(manager.getBranchId());
} else if (cause == null) {
cause = new SystemException(e.errorCode);
}
}
}
}
} catch (XAException e) {
throw (SystemException) new SystemException("Error during rolling back").initCause(e);
}

synchronized (this) {
status = Status.STATUS_ROLLEDBACK;
@@ -630,7 +638,7 @@ private void rollbackResourcesDuringCommit(List rms, boolean everRb) throws Heur
everRolledback = true;
} catch (XAException e) {
if (e.errorCode == XAException.XA_HEURRB) {
// let's not set the cause here
// let's not set the cause here as the resulting behavior is same as requested behavior
log.error("Transaction has been heuristically rolled back " + manager.getCommitter() + "; continuing with rollback", e);
everRolledback = true;
manager.getCommitter().forget(manager.getBranchId());
@@ -649,22 +657,22 @@ private void rollbackResourcesDuringCommit(List rms, boolean everRb) throws Heur
}
}
} catch (XAException e) {
throw (SystemException) new SystemException("Error during rolling back").initCause(e);
throw (SystemException) new SystemException("System error during commit/rolling back").initCause(e);
}

synchronized (this) {
status = Status.STATUS_ROLLEDBACK;
}

if (cause == null) {
throw (RollbackException) new RollbackException("Error during two phase commit").initCause(cause);
throw (RollbackException) new RollbackException("Unable to commit: transaction marked for rollback").initCause(cause);
} else {
if (cause.errorCode == XAException.XA_HEURCOM && everRolledback) {
throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
throw (HeuristicMixedException) new HeuristicMixedException("HeuristicMixed error during commit/rolling back").initCause(cause);
} else if (cause.errorCode == XAException.XA_HEURMIX) {
throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
throw (HeuristicMixedException) new HeuristicMixedException("HeuristicMixed error during commit/rolling back").initCause(cause);
} else {
throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
throw (SystemException) new SystemException("System Error during commit/rolling back").initCause(cause);
}
}
}

0 comments on commit 02fc9bc

Please sign in to comment.