You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dl...@apache.org on 2017/11/02 03:21:23 UTC

[12/50] [abbrv] incubator-edgent git commit: fix TrackingScheduledExecutor CME seen with testMultiTopologyPollWithError() Jenkins #118

fix TrackingScheduledExecutor CME seen with
testMultiTopologyPollWithError() Jenkins #118

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/d50be305
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/d50be305
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/d50be305

Branch: refs/heads/develop
Commit: d50be305b178132cb7b546d600d9b58c48d069d0
Parents: bab6c94
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Wed Oct 25 09:55:21 2017 -0400
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Wed Oct 25 09:55:21 2017 -0400

----------------------------------------------------------------------
 .../edgent/runtime/etiao/TrackingScheduledExecutor.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/d50be305/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/TrackingScheduledExecutor.java
----------------------------------------------------------------------
diff --git a/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/TrackingScheduledExecutor.java b/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/TrackingScheduledExecutor.java
index c4dc44d..478e419 100644
--- a/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/TrackingScheduledExecutor.java
+++ b/runtime/etiao/src/main/java/org/apache/edgent/runtime/etiao/TrackingScheduledExecutor.java
@@ -118,6 +118,14 @@ public final class TrackingScheduledExecutor extends ScheduledThreadPoolExecutor
     private int cancelAllAsyncTasks(boolean mayInterruptIfRunning) {
         int notCanceled = 0;
         synchronized (asyncTasks) {
+            // hmm have gotten CMEs here with testMultiTopologyPollWithError.
+            // This seems to follow the required access pattern for synchronized collection iterator.
+            // But obviously something's amiss.  There seem to be only a few other
+            // asyncTasks modifiers:
+            //    trackTask() - add
+            //    hasActiveTasks() - iterates while synchronized and can remove
+            //    removeTrack() - remove
+            // Just to make things iron clad, synch the add and remove too
             for (RunnableScheduledFuture<?> task : asyncTasks) {
                 if (!task.cancel(mayInterruptIfRunning))
                     notCanceled++;
@@ -134,7 +142,7 @@ public final class TrackingScheduledExecutor extends ScheduledThreadPoolExecutor
      */
     private <V> RunnableScheduledFuture<V> trackTask(RunnableScheduledFuture<V> task) {
         task = new TrackedFuture<V>(task);
-        asyncTasks.add(task);
+        synchronized(asyncTasks) { asyncTasks.add(task); } // see cancelAllAsyncTasks
         return task;
     }
 
@@ -214,7 +222,7 @@ public final class TrackingScheduledExecutor extends ScheduledThreadPoolExecutor
          * the scheduler seems to have no work.
          */
         private void removeTrack() {
-            asyncTasks.remove(this);
+            synchronized(asyncTasks) { asyncTasks.remove(this); } // see cancelAllAsyncTasks
 
             // Notify the completer if the following is true:
             // no asyncTasks (user tasks) pending, or the executor's task