Github user tnachen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4027#discussion_r38496861
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/CoarseMesosSchedulerBackend.scala
 ---
    @@ -357,30 +380,34 @@ 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 = {
    --- End diff --
    
    You're right, I've updated it now.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to