[jboss-svn-commits] JBL Code SVN: r37572 - in labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA: jta and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Oct 17 08:58:12 EDT 2011
Author: jhalliday
Date: 2011-10-17 08:58:11 -0400 (Mon, 17 Oct 2011)
New Revision: 37572
Modified:
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
Backport XAResource recovery leak fix. JBTM-924
Property changes on: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA
___________________________________________________________________
Modified: svn:mergeinfo
- /labs/jbosstm/trunk/ArjunaJTA:36765
+ /labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA:37537
/labs/jbosstm/trunk/ArjunaJTA:36765
Property changes on: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta
___________________________________________________________________
Modified: svn:mergeinfo
- /labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta:37161
/labs/jbosstm/trunk/ArjunaJTA/jta:36765
+ /labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta:37161,37537
/labs/jbosstm/trunk/ArjunaJTA/jta:36765
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-10-17 11:28:33 UTC (rev 37571)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-10-17 12:58:11 UTC (rev 37572)
@@ -41,7 +41,8 @@
public RecoveryXids (XAResource xares)
{
- _xares = xares;
+ _xares = xares;
+ _lastValidated = System.currentTimeMillis();
}
public boolean equals (Object obj)
@@ -135,6 +136,14 @@
return _whenFirstSeen.containsKey(xidImple);
}
+ public boolean isStale() {
+ long now = System.currentTimeMillis();
+ long threshold = _lastValidated+(2*safetyIntervalMillis);
+ long diff = now - threshold;
+ boolean result = diff > 0;
+ return result;
+ }
+
/**
* If supplied xids contains any values seen on prev scans, replace the existing
* XAResource with the supplied one and return true. Otherwise, return false.
@@ -149,6 +158,7 @@
for(int i = 0; i < xids.length; i++) {
if(contains(xids[i])) {
_xares = xaResource;
+ _lastValidated = System.currentTimeMillis();
return true;
}
}
@@ -158,6 +168,7 @@
// so fallback to isSameRM as we can't use Xid matching
if(isSameRM(xaResource)) {
_xares = xaResource;
+ _lastValidated = System.currentTimeMillis();
return true;
}
@@ -170,6 +181,7 @@
private final Map<XidImple,Long> _whenLastSeen = new HashMap<XidImple, Long>();
private XAResource _xares;
+ private long _lastValidated;
private static final int safetyIntervalMillis = 10000; // may eventually want to make this configurable?
}
\ No newline at end of file
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-10-17 11:28:33 UTC (rev 37571)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-10-17 12:58:11 UTC (rev 37572)
@@ -94,7 +94,6 @@
}
}
-
/**
* @message com.arjuna.ats.internal.jta.recovery.xafirstpass {0} - first
* pass
@@ -193,13 +192,8 @@
+ ".transactionInitiatedRecovery completed");
}
- /*
- * See the comment about this routine!!
- */
+ bottomUpRecovery();
- resourceInitiatedRecovery();
- resourceInitiatedRecoveryForRecoveryHelpers();
-
if (jtaLogger.logger.isDebugEnabled())
{
jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
@@ -241,8 +235,7 @@
public XAResource getNewXAResource(Xid xid)
{
if (_xidScans == null) {
- resourceInitiatedRecovery();
- resourceInitiatedRecoveryForRecoveryHelpers();
+ bottomUpRecovery();
}
if (_xidScans != null)
@@ -486,6 +479,8 @@
{
if (recoveryStatus == XARecoveryResource.WAITING_FOR_RECOVERY)
{
+ // resource initiated recovery not possible (no distribution).
+
problem = false;
if (jtaLogger.loggerI18N
@@ -613,6 +608,25 @@
return true;
}
+ private void bottomUpRecovery() {
+
+ // scan using statically configured plugins;
+ resourceInitiatedRecovery();
+ // scan using dynamically configured plugins:
+ resourceInitiatedRecoveryForRecoveryHelpers();
+
+ // garbage collection:
+ if (_xidScans != null) {
+ Set<XAResource> keys = new HashSet<XAResource>(_xidScans.keySet());
+ for(XAResource theKey : keys) {
+ RecoveryXids recoveryXids = _xidScans.get(theKey);
+ if(recoveryXids.isStale()) {
+ _xidScans.remove(theKey);
+ }
+ }
+ }
+ }
+
/**
* Now check for any outstanding transactions. If we didn't fail to recover
* them, then roll them back - if they'd got through prepare we would have
More information about the jboss-svn-commits
mailing list