Github user dragos commented on a diff in the pull request:
https://github.com/apache/spark/pull/4027#discussion_r38499472
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/CoarseMesosSchedulerBackend.scala
---
@@ -357,35 +379,39 @@ private[spark] class CoarseMesosSchedulerBackend(
* slave IDs that we might have asked to be killed. It also notifies the
driver
* that an executor was removed.
*/
- private def executorTerminated(d: SchedulerDriver, slaveId: String,
reason: String): Unit = {
+ private def executorTerminated(
+ d: SchedulerDriver,
+ executorId: String,
+ slaveId: String,
+ reason: String): Unit = {
stateLock.synchronized {
- if (slaveIdsWithExecutors.contains(slaveId)) {
- val slaveIdToTaskId = taskIdToSlaveId.inverse()
- if (slaveIdToTaskId.containsKey(slaveId)) {
- val taskId: Int = slaveIdToTaskId.get(slaveId)
- taskIdToSlaveId.remove(taskId)
- removeExecutor(sparkExecutorId(slaveId, taskId.toString), reason)
+ if (slaveIdsWithExecutors.contains(slaveId) &&
taskIdToSlaveId.contains(executorId)) {
+ taskIdToSlaveId.remove(executorId)
+ removeExecutor(executorId, reason)
+ val newCount = slaveIdsWithExecutors(slaveId) - 1
+ if (newCount == 0) {
+ slaveIdsWithExecutors.remove(slaveId)
+ } else {
+ slaveIdsWithExecutors(slaveId) = newCount
}
- // TODO: This assumes one Spark executor per Mesos slave,
- // which may no longer be true after SPARK-5095
- pendingRemovedSlaveIds -= slaveId
- slaveIdsWithExecutors -= slaveId
}
}
}
- private def sparkExecutorId(slaveId: String, taskId: String): String = {
- s"$slaveId/$taskId"
- }
-
override def slaveLost(d: SchedulerDriver, slaveId: SlaveID): Unit = {
logInfo(s"Mesos slave lost: ${slaveId.getValue}")
- executorTerminated(d, slaveId.getValue, "Mesos slave lost: " +
slaveId.getValue)
+ // Terminate all executors in the slave
+ stateLock.synchronized {
+ val lostExecutors =
taskIdToSlaveId.filter(_._2.equals(slaveId.getValue)).map(_._1)
+ lostExecutors.foreach { taskId =>
+ executorTerminated(d, taskId, slaveId.getValue, "Mesos slave lost:
" + slaveId.getValue)
+ }
+ }
}
override def executorLost(d: SchedulerDriver, e: ExecutorID, s: SlaveID,
status: Int): Unit = {
- logInfo("Executor lost: %s, marking slave %s as
lost".format(e.getValue, s.getValue))
- slaveLost(d, s)
+ logInfo("Executor lost: %s".format(e.getValue))
--- End diff --
Nitpicking: you could use string interpolation: `s"Executor lost:
${e.getValue}"`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]