Skip to content

Commit e6d0841

Browse files
committed
Use a separate lock for stop
1 parent 379b0b0 commit e6d0841

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/src/main/scala/org/apache/spark/scheduler/cluster/StandaloneSchedulerBackend.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ private[spark] class StandaloneSchedulerBackend(
5555
private val maxCores = conf.getOption("spark.cores.max").map(_.toInt)
5656
private val totalExpectedCores = maxCores.getOrElse(0)
5757

58+
/** Lock for `stop(finalState: SparkAppHandle.State)` method. */
59+
private val stopLock = new Object
60+
5861
override def start() {
5962
super.start()
6063
launcherBackend.connect()
@@ -112,7 +115,7 @@ private[spark] class StandaloneSchedulerBackend(
112115
launcherBackend.setState(SparkAppHandle.State.RUNNING)
113116
}
114117

115-
override def stop(): Unit = synchronized {
118+
override def stop(): Unit = {
116119
stop(SparkAppHandle.State.FINISHED)
117120
}
118121

@@ -206,7 +209,7 @@ private[spark] class StandaloneSchedulerBackend(
206209
registrationBarrier.release()
207210
}
208211

209-
private def stop(finalState: SparkAppHandle.State): Unit = synchronized {
212+
private def stop(finalState: SparkAppHandle.State): Unit = stopLock.synchronized {
210213
try {
211214
stopping = true
212215

0 commit comments

Comments
 (0)