[jboss-svn-commits] JBL Code SVN: r37537 - labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Oct 14 12:16:44 EDT 2011
Author: jhalliday
Date: 2011-10-14 12:16:44 -0400 (Fri, 14 Oct 2011)
New Revision: 37537
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
Plug resource leak in xa recovery. JBTM-924
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-10-14 13:32:13 UTC (rev 37536)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-10-14 16:16:44 UTC (rev 37537)
@@ -1,20 +1,20 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
* See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
- *
+ *
* (C) 2005-2006,
* @author JBoss Inc.
*/
@@ -41,9 +41,10 @@
public RecoveryXids (XAResource xares)
{
- _xares = xares;
+ _xares = xares;
+ _lastValidated = System.currentTimeMillis();
}
-
+
public boolean equals (Object obj)
{
if (obj instanceof RecoveryXids)
@@ -127,14 +128,22 @@
return false;
}
}
-
+
public boolean contains (Xid xid)
{
XidImple xidImple = new XidImple(xid);
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_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-10-14 13:32:13 UTC (rev 37536)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-10-14 16:16:44 UTC (rev 37537)
@@ -91,7 +91,7 @@
}
}
}
-
+
public void removeXAResourceOrphanFilter(XAResourceOrphanFilter xaResourceOrphanFilter) {
synchronized (_xaResourceOrphanFilters) {
_xaResourceOrphanFilters.remove(xaResourceOrphanFilter);
@@ -146,13 +146,8 @@
+ ".transactionInitiatedRecovery completed");
}
- /*
- * See the comment about this routine!!
- */
+ bottomUpRecovery();
- resourceInitiatedRecovery();
- resourceInitiatedRecoveryForRecoveryHelpers();
-
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug(_logName
+ ".resourceInitiatedRecovery completed");
@@ -181,8 +176,7 @@
private XAResource getNewXAResource(Xid xid)
{
if (_xidScans == null) {
- resourceInitiatedRecovery();
- resourceInitiatedRecoveryForRecoveryHelpers();
+ bottomUpRecovery();
}
if (_xidScans != null)
@@ -270,7 +264,7 @@
if (recoveryStatus == XARecoveryResource.WAITING_FOR_RECOVERY)
{
// resource initiated recovery not possible (no distribution).
-
+
problem = false;
jtaLogger.i18NLogger.info_recovery_recoverydelayed(theUid, Integer.toString(recoveryStatus));
@@ -353,6 +347,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
@@ -496,7 +509,7 @@
else
{
refreshXidScansForEquivalentXAResourceImpl(xares, trans);
-
+
xidsToRecover = _xidScans.get(xares);
if (xidsToRecover == null)
More information about the jboss-svn-commits
mailing list