Skip to content

Commit ea0bf91

Browse files
WangTaoTheTonicMarcelo Vanzin
authored and
Marcelo Vanzin
committed
[SPARK-17022][YARN] Handle potential deadlock in driver handling messages
## What changes were proposed in this pull request? We directly send RequestExecutors to AM instead of transfer it to yarnShedulerBackend first, to avoid potential deadlock. ## How was this patch tested? manual tests Author: WangTaoTheTonic <[email protected]> Closes apache#14605 from WangTaoTheTonic/lock.
1 parent 4ec5c36 commit ea0bf91

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnSchedulerBackend.scala

+15-3
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,20 @@ private[spark] abstract class YarnSchedulerBackend(
125125
* This includes executors already pending or running.
126126
*/
127127
override def doRequestTotalExecutors(requestedTotal: Int): Boolean = {
128-
yarnSchedulerEndpointRef.askWithRetry[Boolean](
129-
RequestExecutors(requestedTotal, localityAwareTasks, hostToLocalTaskCount))
128+
val r = RequestExecutors(requestedTotal, localityAwareTasks, hostToLocalTaskCount)
129+
yarnSchedulerEndpoint.amEndpoint match {
130+
case Some(am) =>
131+
try {
132+
am.askWithRetry[Boolean](r)
133+
} catch {
134+
case NonFatal(e) =>
135+
logError(s"Sending $r to AM was unsuccessful", e)
136+
return false
137+
}
138+
case None =>
139+
logWarning("Attempted to request executors before the AM has registered!")
140+
return false
141+
}
130142
}
131143

132144
/**
@@ -209,7 +221,7 @@ private[spark] abstract class YarnSchedulerBackend(
209221
*/
210222
private class YarnSchedulerEndpoint(override val rpcEnv: RpcEnv)
211223
extends ThreadSafeRpcEndpoint with Logging {
212-
private var amEndpoint: Option[RpcEndpointRef] = None
224+
var amEndpoint: Option[RpcEndpointRef] = None
213225

214226
private val askAmThreadPool =
215227
ThreadUtils.newDaemonCachedThreadPool("yarn-scheduler-ask-am-thread-pool")

0 commit comments

Comments
 (0)