You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/10/13 08:27:03 UTC
incubator-kylin git commit: minor,
log stack trace of bad query thread for further analysis
Repository: incubator-kylin
Updated Branches:
refs/heads/1.x-staging 92c0d1a2b -> 6023dff55
minor, log stack trace of bad query thread for further analysis
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/6023dff5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/6023dff5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/6023dff5
Branch: refs/heads/1.x-staging
Commit: 6023dff554a5745cfdde625f4a364ff3f3a54043
Parents: 92c0d1a
Author: Li, Yang <ya...@ebay.com>
Authored: Tue Oct 13 14:26:19 2015 +0800
Committer: Li, Yang <ya...@ebay.com>
Committed: Tue Oct 13 14:26:52 2015 +0800
----------------------------------------------------------------------
.../kylin/rest/service/BadQueryDetector.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/6023dff5/server/src/main/java/org/apache/kylin/rest/service/BadQueryDetector.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/service/BadQueryDetector.java b/server/src/main/java/org/apache/kylin/rest/service/BadQueryDetector.java
index e7ea8d1..49147d3 100644
--- a/server/src/main/java/org/apache/kylin/rest/service/BadQueryDetector.java
+++ b/server/src/main/java/org/apache/kylin/rest/service/BadQueryDetector.java
@@ -20,7 +20,6 @@ package org.apache.kylin.rest.service;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import org.apache.kylin.rest.request.SQLRequest;
@@ -140,13 +139,11 @@ public class BadQueryDetector extends Thread {
if (getSystemAvailMB() < alertMB) {
logger.info("System free memory less than " + alertMB + " MB. " + entries.size() + " queries running.");
- for (Map.Entry<Thread, Entry> mapEntry : runningQueries.entrySet()) {
- Entry e = mapEntry.getValue();
+ for (Entry e : entries) {
int duration = (int) ((now - e.startTime) / 1000);
if (duration > killRunningSec) {
notify("Kill", duration, e.sqlRequest.getSql(), e.thread);
- Thread queryThread = mapEntry.getKey();
- killQueryThread(queryThread);
+ killQueryThread(e.thread);
} else {
notify("Low mem", duration, e.sqlRequest.getSql(), e.thread);
}
@@ -154,8 +151,17 @@ public class BadQueryDetector extends Thread {
}
}
- private void killQueryThread(Thread thread) {
- thread.interrupt();
+ private void killQueryThread(Thread t) {
+ StackTraceElement[] stackTrace = t.getStackTrace();
+ t.interrupt();
+
+ // log the stack trace of bad query thread for further analysis
+ StringBuilder buf = new StringBuilder("Interrupted thread 0x" + Long.toHexString(t.getId()));
+ buf.append("\n");
+ for (StackTraceElement e : stackTrace) {
+ buf.append("\t").append("at ").append(e.toString()).append("\n");
+ }
+ logger.info(buf.toString());
}
public static final int ONE_MB = 1024 * 1024;