From 7085daa95f96bcf65447e4bb5f39d9014a663614 Mon Sep 17 00:00:00 2001 From: Michael Allman Date: Mon, 11 Jan 2016 11:13:01 -0800 Subject: [PATCH 1/3] [SPARK-6950][CORE] Stop the event logger before the DAG scheduler to avoid a race condition where the standalone master attempts to build the app's history UI before the event log is stopped --- core/src/main/scala/org/apache/spark/SparkContext.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index 98075cef112db..f9a5c74274694 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -1681,6 +1681,9 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli Utils.tryLogNonFatalError { _executorAllocationManager.foreach(_.stop()) } + Utils.tryLogNonFatalError { + _eventLogger.foreach(_.stop()) + } if (_dagScheduler != null) { Utils.tryLogNonFatalError { _dagScheduler.stop() @@ -1693,9 +1696,6 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli _listenerBusStarted = false } } - Utils.tryLogNonFatalError { - _eventLogger.foreach(_.stop()) - } if (env != null && _heartbeatReceiver != null) { Utils.tryLogNonFatalError { env.rpcEnv.stop(_heartbeatReceiver) From 6c32f77890d8ac5f2117020a65167e27124aeae5 Mon Sep 17 00:00:00 2001 From: Michael Allman Date: Sun, 17 Jan 2016 22:22:33 -0800 Subject: [PATCH 2/3] Stop the listener bus before the event logger --- .../main/scala/org/apache/spark/SparkContext.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index f9a5c74274694..5b0db361f0d77 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -1684,18 +1684,18 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli Utils.tryLogNonFatalError { _eventLogger.foreach(_.stop()) } - if (_dagScheduler != null) { - Utils.tryLogNonFatalError { - _dagScheduler.stop() - } - _dagScheduler = null - } if (_listenerBusStarted) { Utils.tryLogNonFatalError { listenerBus.stop() _listenerBusStarted = false } } + if (_dagScheduler != null) { + Utils.tryLogNonFatalError { + _dagScheduler.stop() + } + _dagScheduler = null + } if (env != null && _heartbeatReceiver != null) { Utils.tryLogNonFatalError { env.rpcEnv.stop(_heartbeatReceiver) From 57cade176fa176d6642a78e2f16430ffdca19a6e Mon Sep 17 00:00:00 2001 From: Michael Allman Date: Mon, 18 Jan 2016 07:34:24 -0800 Subject: [PATCH 3/3] Stop the event logger after the event listeners and before the DAG scheduler, take 3. This was my original intention, bungled twice :/ --- core/src/main/scala/org/apache/spark/SparkContext.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index 5b0db361f0d77..baf6b413bb290 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -1681,15 +1681,15 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli Utils.tryLogNonFatalError { _executorAllocationManager.foreach(_.stop()) } - Utils.tryLogNonFatalError { - _eventLogger.foreach(_.stop()) - } if (_listenerBusStarted) { Utils.tryLogNonFatalError { listenerBus.stop() _listenerBusStarted = false } } + Utils.tryLogNonFatalError { + _eventLogger.foreach(_.stop()) + } if (_dagScheduler != null) { Utils.tryLogNonFatalError { _dagScheduler.stop()