-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-6650] [core] Stop ExecutorAllocationManager when context stops. #5311
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ package org.apache.spark | |
|
||
import scala.collection.mutable | ||
|
||
import org.scalatest.{FunSuite, PrivateMethodTester} | ||
import org.scalatest.{BeforeAndAfter, FunSuite, PrivateMethodTester} | ||
import org.apache.spark.executor.TaskMetrics | ||
import org.apache.spark.scheduler._ | ||
import org.apache.spark.scheduler.cluster.ExecutorInfo | ||
|
@@ -28,29 +28,40 @@ import org.apache.spark.util.ManualClock | |
/** | ||
* Test add and remove behavior of ExecutorAllocationManager. | ||
*/ | ||
class ExecutorAllocationManagerSuite extends FunSuite with LocalSparkContext { | ||
class ExecutorAllocationManagerSuite extends FunSuite with LocalSparkContext with BeforeAndAfter { | ||
import ExecutorAllocationManager._ | ||
import ExecutorAllocationManagerSuite._ | ||
|
||
private val contexts = new mutable.ListBuffer[SparkContext]() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this ever have more than a single element? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. See |
||
|
||
before { | ||
contexts.clear() | ||
} | ||
|
||
after { | ||
contexts.foreach(_.stop()) | ||
} | ||
|
||
test("verify min/max executors") { | ||
val conf = new SparkConf() | ||
.setMaster("local") | ||
.setAppName("test-executor-allocation-manager") | ||
.set("spark.dynamicAllocation.enabled", "true") | ||
.set("spark.dynamicAllocation.testing", "true") | ||
val sc0 = new SparkContext(conf) | ||
contexts += sc0 | ||
assert(sc0.executorAllocationManager.isDefined) | ||
sc0.stop() | ||
|
||
// Min < 0 | ||
val conf1 = conf.clone().set("spark.dynamicAllocation.minExecutors", "-1") | ||
intercept[SparkException] { new SparkContext(conf1) } | ||
intercept[SparkException] { contexts += new SparkContext(conf1) } | ||
SparkEnv.get.stop() | ||
SparkContext.clearActiveContext() | ||
|
||
// Max < 0 | ||
val conf2 = conf.clone().set("spark.dynamicAllocation.maxExecutors", "-1") | ||
intercept[SparkException] { new SparkContext(conf2) } | ||
intercept[SparkException] { contexts += new SparkContext(conf2) } | ||
SparkEnv.get.stop() | ||
SparkContext.clearActiveContext() | ||
|
||
|
@@ -665,16 +676,6 @@ class ExecutorAllocationManagerSuite extends FunSuite with LocalSparkContext { | |
assert(removeTimes(manager).contains("executor-2")) | ||
assert(!removeTimes(manager).contains("executor-1")) | ||
} | ||
} | ||
|
||
/** | ||
* Helper methods for testing ExecutorAllocationManager. | ||
* This includes methods to access private methods and fields in ExecutorAllocationManager. | ||
*/ | ||
private object ExecutorAllocationManagerSuite extends PrivateMethodTester { | ||
private val schedulerBacklogTimeout = 1L | ||
private val sustainedSchedulerBacklogTimeout = 2L | ||
private val executorIdleTimeout = 3L | ||
|
||
private def createSparkContext(minExecutors: Int = 1, maxExecutors: Int = 5): SparkContext = { | ||
val conf = new SparkConf() | ||
|
@@ -688,9 +689,22 @@ private object ExecutorAllocationManagerSuite extends PrivateMethodTester { | |
sustainedSchedulerBacklogTimeout.toString) | ||
.set("spark.dynamicAllocation.executorIdleTimeout", executorIdleTimeout.toString) | ||
.set("spark.dynamicAllocation.testing", "true") | ||
new SparkContext(conf) | ||
val sc = new SparkContext(conf) | ||
contexts += sc | ||
sc | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Helper methods for testing ExecutorAllocationManager. | ||
* This includes methods to access private methods and fields in ExecutorAllocationManager. | ||
*/ | ||
private object ExecutorAllocationManagerSuite extends PrivateMethodTester { | ||
private val schedulerBacklogTimeout = 1L | ||
private val sustainedSchedulerBacklogTimeout = 2L | ||
private val executorIdleTimeout = 3L | ||
|
||
private def createStageInfo(stageId: Int, numTasks: Int): StageInfo = { | ||
new StageInfo(stageId, 0, "name", numTasks, Seq.empty, "no details") | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking aloud here:
We stop the ExecutorAllocationManager after stopping the DAGScheduler, which means, in yarn-client mode, we'll have already torn down the YARN application. If
schedule
is called after that, we could be trying to make an RPC to the AM, which is no longer there. So it seems like waiting the full 10 seconds for that RPC to time out could be a common case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to follow the order of initialization during shutdown (the alloc manager is started after the event logger so should be stopped right before it - yeah, I know my code doesn't do exactly that).
But we could move the stop before the scheduler's stop.