aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinweizhong <linweizhong@huawei.com>2015-09-17 22:25:24 -0700
committerYin Huai <yhuai@databricks.com>2015-09-17 22:25:24 -0700
commit93c7650ab60a839a9cbe8b4ea1d5eda93e53ebe0 (patch)
tree28526e76b146b64e848f590f3c6f3d848a332e9d
parentd009da2f5c803f3b7344c96abbfcf3ecef2f5ad2 (diff)
downloadspark-93c7650ab60a839a9cbe8b4ea1d5eda93e53ebe0.tar.gz
spark-93c7650ab60a839a9cbe8b4ea1d5eda93e53ebe0.tar.bz2
spark-93c7650ab60a839a9cbe8b4ea1d5eda93e53ebe0.zip
[SPARK-9522] [SQL] SparkSubmit process can not exit if kill application when HiveThriftServer was starting
When we start HiveThriftServer, we will start SparkContext first, then start HiveServer2, if we kill application while HiveServer2 is starting then SparkContext will stop successfully, but SparkSubmit process can not exit. Author: linweizhong <linweizhong@huawei.com> Closes #7853 from Sephiroth-Lin/SPARK-9522.
-rw-r--r--core/src/main/scala/org/apache/spark/SparkContext.scala2
-rw-r--r--sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala6
2 files changed, 7 insertions, 1 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala
index 9c3218719f..ebd8e946ee 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -97,7 +97,7 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
val startTime = System.currentTimeMillis()
- private val stopped: AtomicBoolean = new AtomicBoolean(false)
+ private[spark] val stopped: AtomicBoolean = new AtomicBoolean(false)
private def assertNotStopped(): Unit = {
if (stopped.get()) {
diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala
index dd9fef9206..a0643cec0f 100644
--- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala
+++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala
@@ -93,6 +93,12 @@ object HiveThriftServer2 extends Logging {
} else {
None
}
+ // If application was killed before HiveThriftServer2 start successfully then SparkSubmit
+ // process can not exit, so check whether if SparkContext was stopped.
+ if (SparkSQLEnv.sparkContext.stopped.get()) {
+ logError("SparkContext has stopped even if HiveServer2 has started, so exit")
+ System.exit(-1)
+ }
} catch {
case e: Exception =>
logError("Error starting HiveThriftServer2", e)