hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jd...@apache.org
Subject [28/58] [abbrv] hive git commit: HIVE-13491 : Testing : log thread stacks when metastore fails to start (Thejas Nair, reviewed by Szehon Ho)
Date Tue, 19 Apr 2016 22:25:20 GMT
HIVE-13491 : Testing : log thread stacks when metastore fails to start (Thejas Nair, reviewed
by Szehon Ho)


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

Branch: refs/heads/llap
Commit: e16bcca649bb55375860917726fab7545717d5c2
Parents: 547b37d
Author: Thejas Nair <thejas@hortonworks.com>
Authored: Tue Apr 12 12:09:47 2016 -0700
Committer: Thejas Nair <thejas@hortonworks.com>
Committed: Tue Apr 12 12:10:11 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hive/metastore/MetaStoreUtils.java   | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/e16bcca6/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
index 866e1c3..76220f4 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
@@ -1209,16 +1209,40 @@ public class MetaStoreUtils {
         socket.close();
         return;
       } catch (Exception e) {
-        if (retries++ > 6) { //give up
+        if (retries++ > 60) { //give up
           exc = e;
           break;
         }
-        Thread.sleep(10000);
+        Thread.sleep(1000);
       }
     }
+    // something is preventing metastore from starting
+    // print the stack from all threads for debugging purposes
+    LOG.error("Unable to connect to metastore server: " + exc.getMessage());
+    LOG.info("Printing all thread stack traces for debugging before throwing exception.");
+    LOG.info(getAllThreadStacksAsString());
     throw exc;
   }
 
+  private static String getAllThreadStacksAsString() {
+    Map<Thread, StackTraceElement[]> threadStacks = Thread.getAllStackTraces();
+    StringBuilder sb = new StringBuilder();
+    for (Map.Entry<Thread, StackTraceElement[]> entry : threadStacks.entrySet()) {
+      Thread t = entry.getKey();
+      sb.append(System.lineSeparator());
+      sb.append("Name: ").append(t.getName()).append(" State: " + t.getState());
+      addStackString(entry.getValue(), sb);
+    }
+    return sb.toString();
+  }
+
+  private static void addStackString(StackTraceElement[] stackElems, StringBuilder sb) {
+    sb.append(System.lineSeparator());
+    for (StackTraceElement stackElem : stackElems) {
+      sb.append(stackElem).append(System.lineSeparator());
+    }
+  }
+
   /**
    * Finds a free port on the machine.
    *


Mime
View raw message