[jboss-svn-commits] JBL Code SVN: r38183 - labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 18 05:35:53 EDT 2012


Author: tomjenkinson
Date: 2012-09-18 05:35:53 -0400 (Tue, 18 Sep 2012)
New Revision: 38183

Modified:
   labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
   labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
JBTM-1255 reverted stale check removal from JBTM-895 back to JBTM-924 state

Modified: labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	2012-09-17 21:40:57 UTC (rev 38182)
+++ labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	2012-09-18 09:35:53 UTC (rev 38183)
@@ -142,6 +142,18 @@
 
         return _whenFirstSeen.containsKey(xidImple);
     }
+
+    // JBTM-924
+    public boolean isStale() {
+        long now = System.currentTimeMillis();
+        // JBTM-1255 - use a different safety declaration for staleness, if you set a safety interval of 0 (using reflection) then 
+        // you will detect everything as stale. The only time we actually set safetyIntervalMillis is in JBTM-895 unit test SimpleIsolatedServers
+        // so in the normal case this will behave as before
+        long threshold = _lastValidated+(2*safetyIntervalMillis < staleSafetyIntervalMillis ? staleSafetyIntervalMillis : 2*safetyIntervalMillis);
+        long diff = now - threshold;
+        boolean result = diff > 0;
+        return result;
+    }
     
     public boolean remove (Xid xid)
     {
@@ -199,6 +211,10 @@
     private XAResource _xares;
     private long _lastValidated;
 
+    /**
+     * JBTM-1255 this is required to reinstate JBTM-924, see message in {@see RecoveryXids#isStale()} 
+     */
+    private static final int staleSafetyIntervalMillis = 20000; // The advice is that this (if made configurable is twice the safety interval) 
     // JBTM-916 removed final so 10000 is not inlined into source code until we make this configurable
 	// https://issues.jboss.org/browse/JBTM-842
     private static int safetyIntervalMillis = 10000; // may eventually want to make this configurable?

Modified: labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	2012-09-17 21:40:57 UTC (rev 38182)
+++ labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	2012-09-18 09:35:53 UTC (rev 38183)
@@ -196,10 +196,6 @@
 			bottomUpRecovery();
         }
 
-		// JBTM-895 updated so that retrieving an XAResource triggers garbage collection, this is required because garbage collecting
-		// The XA resources in a bottom up scenario (e.g. resourceInitiatedRecoveryForRecoveryHelpers) means that any xids that are
-		// not eligible for recovery after the first scan may be removed as stale and due to the undocumented _xidScans check above will not be
-		// reloaded
         if (_xidScans != null)
 		{
 			Enumeration<XAResource> keys = _xidScans.keys();
@@ -209,12 +205,9 @@
 				XAResource theKey = keys.nextElement();
 				RecoveryXids xids = _xidScans.get(theKey);
 
-				if (xids.remove(xid)) {
-					if (xids.isEmpty()) {
-						_xidScans.remove(theKey);
-					}
+				// JBTM-1255 moved stale check back to bottomUpRecovery
+				if (xids.contains(xid))
 					return theKey;
-				}
 			}
 		}
 
@@ -385,6 +378,16 @@
         resourceInitiatedRecoveryForRecoveryHelpers();
 
         // JBTM-895 garbage collection is now done when we return XAResources {@see XARecoveryModule#getNewXAResource(XAResourceRecord)}
+        // JBTM-924 requires this here garbage collection, see JBTM-1155:
+        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);
+                }
+            }
+        }
     }
 
 	/**



More information about the jboss-svn-commits mailing list