ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [43/50] [abbrv] ignite git commit: debugging TC hangs
Date Mon, 05 Dec 2016 14:42:05 GMT
debugging TC hangs


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/65fc89f3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/65fc89f3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/65fc89f3

Branch: refs/heads/ignite-comm-balance-master
Commit: 65fc89f3a8f951b8568e6585affd8274976d4248
Parents: 6414b3f
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Thu Dec 1 19:12:31 2016 +0700
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Thu Dec 1 19:12:31 2016 +0700

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       |  2 +-
 .../ignite/internal/util/StripedExecutor.java   | 52 ++++++++++++++++----
 2 files changed, 44 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/65fc89f3/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index aefcbb5..e95fa18 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -1302,7 +1302,7 @@ public abstract class IgniteUtils {
     public static void printStackTrace(long threadId, GridStringBuilder sb) {
         ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
 
-        ThreadInfo threadInfo = mxBean.getThreadInfo(threadId);
+        ThreadInfo threadInfo = mxBean.getThreadInfo(threadId, Integer.MAX_VALUE);
 
         printThreadInfo(threadInfo, sb, Collections.<Long>emptySet());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/65fc89f3/modules/core/src/main/java/org/apache/ignite/internal/util/StripedExecutor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/StripedExecutor.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/StripedExecutor.java
index 189d64e..7db75bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/StripedExecutor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/StripedExecutor.java
@@ -67,9 +67,11 @@ public class StripedExecutor implements ExecutorService {
                 stripes[i].start();
             }
 
-            // TODO
+            // TODO - move to starvation checker
             Thread t = new Thread(new Runnable() {
                 @Override public void run() {
+                    long[] cntrs = new long[stripes.length];
+
                     for (; !isShutdown();) {
                         try {
                             Thread.sleep(10_000);
@@ -78,8 +80,13 @@ public class StripedExecutor implements ExecutorService {
                             return;
                         }
 
-                        for (Stripe stripe : stripes) {
-                            if (stripe.queueSize() > 0) {
+                        for (int i = 0; i < stripes.length; i++) {
+                            Stripe stripe = stripes[i];
+
+                            long completedCnt = stripe.completedCnt;
+
+                            if (cntrs[i] == completedCnt &&
+                                stripe.active) {
                                 boolean deadlockPresent = U.deadlockPresent();
 
                                 GridStringBuilder sb = new GridStringBuilder();
@@ -87,15 +94,24 @@ public class StripedExecutor implements ExecutorService {
                                 sb.a(">>> Possible starvation in striped pool: ")
                                     .a(stripe.thread.getName()).a(U.nl())
                                     .a(stripe.queueToString()).a(U.nl())
-                                    .a("deadlock: ").a(deadlockPresent).a(U.nl());
+                                    .a("deadlock: ").a(deadlockPresent).a(U.nl())
+                                    .a("completed: ").a(completedCnt).a(U.nl());
 
-                                U.printStackTrace(stripe.thread.getId(), sb);
+                                U.printStackTrace(
+                                    stripe.thread.getId(),
+                                    sb);
 
                                 String msg = sb.toString();
 
-                                U.warn(log, msg);
-                                U.warn(null, msg);
+                                U.warn(
+                                    log,
+                                    msg);
+                                U.warn(
+                                    null,
+                                    msg);
                             }
+                            else
+                                cntrs[i] = completedCnt;
                         }
                     }
                 }
@@ -337,6 +353,12 @@ public class StripedExecutor implements ExecutorService {
         /** Stopping flag. */
         private volatile boolean stopping;
 
+        /** */
+        private volatile long completedCnt;
+
+        /** */
+        private volatile boolean active;
+
         /** Thread executing the loop. */
         protected Thread thread;
 
@@ -399,8 +421,17 @@ public class StripedExecutor implements ExecutorService {
                 try {
                     cmd = take();
 
-                    if (cmd != null)
-                        cmd.run();
+                    if (cmd != null) {
+                        active = true;
+
+                        try {
+                            cmd.run();
+                        }
+                        finally {
+                            active = false;
+                            completedCnt++;
+                        }
+                    }
                 }
                 catch (InterruptedException e) {
                     stopping = true;
@@ -433,6 +464,9 @@ public class StripedExecutor implements ExecutorService {
          */
         abstract int queueSize();
 
+        /**
+         * @return Stripe's queue to string presentation.
+         */
         abstract String queueToString();
 
         /** {@inheritDoc} */


Mime
View raw message