Skip to content
Permalink
Browse files
GERONIMO-5152 restore logic about results of a heuristic rollback. Cl…
…ean up pom

git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@939929 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
djencks committed May 1, 2010
1 parent 81fabfe commit 24cc0422d3a7df50fcd577322c946ce30fe01a93
Showing 3 changed files with 24 additions and 83 deletions.
@@ -48,6 +48,7 @@ public class CommitTask implements Runnable {
private int count = 0;
private int status;
private XAException cause;
private boolean evercommit;

public CommitTask(Xid xid, List<TransactionBranch> rms, Object logMark, RetryScheduler retryScheduler, TransactionLog txLog) {
this.xid = xid;
@@ -80,11 +81,13 @@ public void run() {
i.remove();
log.info("Transaction has been heuristically committed and rolled back");
cause = e;
evercommit = true;
manager.getCommitter().forget(manager.getBranchId());
} else if (e.errorCode == XAException.XA_HEURCOM) {
i.remove();
// let's not throw an exception as the transaction has been committed
log.info("Transaction has been heuristically committed");
evercommit = true;
manager.getCommitter().forget(manager.getBranchId());
} else if (e.errorCode == XAException.XA_RETRY) {
// do nothing, retry later
@@ -117,23 +120,16 @@ public void run() {
} else {
retryScheduler.retry(this, count++);
}
// if (cause != null) {
// if (cause.errorCode == XAException.XA_HEURRB && !evercommit) {
// throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
// } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
// } else if (cause.errorCode == XAException.XA_HEURMIX) {
// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
// } else {
// throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
// }
// }
}

public XAException getCause() {
return cause;
}

public boolean isEvercommit() {
return evercommit;
}

public int getStatus() {
return status;
}
@@ -746,7 +746,6 @@ private void commitResource(TransactionBranch manager) throws RollbackException,
}

private void commitResources(List<TransactionBranch> rms) throws HeuristicRollbackException, HeuristicMixedException, SystemException {
//TODO there's some logic removed about dealing with a heuristic rollback on the first resource.
CommitTask commitTask = new CommitTask(xid, rms, logMark, retryScheduler, txnLog);
synchronized (this) {
status = Status.STATUS_COMMITTING;
@@ -756,10 +755,11 @@ private void commitResources(List<TransactionBranch> rms) throws HeuristicRollba
status = commitTask.getStatus();
}
XAException cause = commitTask.getCause();
boolean evercommit = commitTask.isEvercommit();
if (cause != null) {
if (cause.errorCode == XAException.XA_HEURRB) {
if (cause.errorCode == XAException.XA_HEURRB&& !evercommit) {
throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
} else if (cause.errorCode == XAException.XA_HEURRB) {
} else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
} else if (cause.errorCode == XAException.XA_HEURMIX) {
throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
@@ -769,67 +769,6 @@ private void commitResources(List<TransactionBranch> rms) throws HeuristicRollba
}


// XAException cause = null;
// boolean evercommit = false;
// try {
// for (Iterator i = rms.iterator(); i.hasNext();) {
// TransactionBranch manager = (TransactionBranch) i.next();
// try {
// manager.getCommitter().commit(manager.getBranchId(), false);
// evercommit = true;
// } catch (XAException e) {
// log.error("Unexpected exception committing " + manager.getCommitter() + "; continuing to commit other RMs", e);
//
// if (e.errorCode == XAException.XA_HEURRB) {
// log.info("Transaction has been heuristically rolled back");
// cause = e;
// manager.getCommitter().forget(manager.getBranchId());
// } else if (e.errorCode == XAException.XA_HEURMIX) {
// log.info("Transaction has been heuristically committed and rolled back");
// cause = e;
// evercommit = true;
// manager.getCommitter().forget(manager.getBranchId());
// } else if (e.errorCode == XAException.XA_HEURCOM) {
// // let's not throw an exception as the transaction has been committed
// log.info("Transaction has been heuristically committed");
// evercommit = true;
// manager.getCommitter().forget(manager.getBranchId());
// } else {
// cause = e;
// }
// }
// }
// } catch (XAException e) {
// if (e.errorCode == XAException.XAER_NOTA) {
// // NOTA in response to forget, means the resource already forgot the transaction
// // ignore
// } else {
// throw (SystemException) new SystemException("Error during two phase commit").initCause(e);
// }
// }
// //if all resources were read only, we didn't write a prepare record.
// if (!rms.isEmpty()) {
// try {
// txnLog.commit(xid, logMark);
// } catch (LogException e) {
// log.error("Unexpected exception logging commit completion for xid " + xid, e);
// throw (SystemException) new SystemException("Unexpected error logging commit completion for xid " + xid).initCause(e);
// }
// }
// synchronized (this) {
// status = Status.STATUS_COMMITTED;
// }
// if (cause != null) {
// if (cause.errorCode == XAException.XA_HEURRB && !evercommit) {
// throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
// } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
// } else if (cause.errorCode == XAException.XA_HEURMIX) {
// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
// } else {
// throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
// }
// }
}

private static String getStateString(int status) {
22 pom.xml
@@ -49,6 +49,19 @@

<dependencyManagement>
<dependencies>
<!-- INTERNAL -->

<dependency>
<groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-transaction</artifactId>
<version>${version}</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-connector</artifactId>
<version>${version}</version>
</dependency>
<!-- external -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -71,7 +84,7 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
<version>1.0-EA-SNAPSHOT</version>
<version>1.0</version>
</dependency>

<dependency>
@@ -87,13 +100,6 @@
<scope>test</scope>
</dependency>

<!-- INTERNAL -->

<dependency>
<groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-transaction</artifactId>
<version>${version}</version>
</dependency>
</dependencies>
</dependencyManagement>

0 comments on commit 24cc042

Please sign in to comment.