You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ke...@apache.org on 2007/03/07 05:36:04 UTC
svn commit: r515447 -
/geronimo/server/branches/1.2/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java
Author: kevan
Date: Tue Mar 6 20:36:03 2007
New Revision: 515447
URL: http://svn.apache.org/viewvc?view=rev&rev=515447
Log:
GERONIMO-2838 Make sure that transaction recovery is handled properly. Multiple NamedXAResources can share a single ResourceManager. Need to be sure that we're only committing/updating XidBranches if the resource was the XAResource used for the transaction.
Modified:
geronimo/server/branches/1.2/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java
Modified: geronimo/server/branches/1.2/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java?view=diff&rev=515447&r1=515446&r2=515447
==============================================================================
--- geronimo/server/branches/1.2/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java (original)
+++ geronimo/server/branches/1.2/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java Tue Mar 6 20:36:03 2007
@@ -97,14 +97,21 @@
Xid xid = prepared[i];
ByteArrayWrapper globalIdWrapper = new ByteArrayWrapper(xid.getGlobalTransactionId());
XidBranchesPair xidNamesPair = (XidBranchesPair) ourXids.get(globalIdWrapper);
+
if (xidNamesPair != null) {
- try {
- xaResource.commit(xid, false);
- } catch (XAException e) {
- recoveryErrors.add(e);
- log.error(e);
+
+ // Only commit if this NamedXAResource was the XAResource for the transaction.
+ // Otherwise, wait for recoverResourceManager to be called for the actual XAResource
+ // This is a bit wasteful, but given our management of XAResources by "name", is about the best we can do.
+ if (isNameInTransaction(xidNamesPair, name)) {
+ try {
+ xaResource.commit(xid, false);
+ } catch(XAException e) {
+ recoveryErrors.add(e);
+ log.error(e);
+ }
+ removeNameFromTransaction(xidNamesPair, name, true);
}
- removeNameFromTransaction(xidNamesPair, name, true);
} else if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) {
//ours, but prepare not logged
try {
@@ -140,6 +147,16 @@
}
}
+ private boolean isNameInTransaction(XidBranchesPair xidBranchesPair, String name) {
+ for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) {
+ TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next();
+ if (name.equals(transactionBranchInfo.getResourceName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void removeNameFromTransaction(XidBranchesPair xidBranchesPair, String name, boolean warn) {
int removed = 0;
for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) {