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

    https://github.com/apache/spark/pull/10993#discussion_r51704761
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/CoarseMesosSchedulerBackend.scala
 ---
    @@ -373,40 +451,25 @@ private[spark] class CoarseMesosSchedulerBackend(
       override def frameworkMessage(d: SchedulerDriver, e: ExecutorID, s: 
SlaveID, b: Array[Byte]) {}
     
       /**
    -   * Called when a slave is lost or a Mesos task finished. Update local 
view on
    -   * what tasks are running and remove the terminated slave from the list 
of pending
    -   * slave IDs that we might have asked to be killed. It also notifies the 
driver
    -   * that an executor was removed.
    +   * Called when a slave is lost or a Mesos task finished. Updates local 
view on
    +   * what tasks are running. 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,
    +                                 slaveId: String,
    +                                 taskId: 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), 
SlaveLost(reason))
    -        }
    -        // TODO: This assumes one Spark executor per Mesos slave,
    -        // which may no longer be true after SPARK-5095
    -        pendingRemovedSlaveIds -= slaveId
    -        slaveIdsWithExecutors -= slaveId
    -      }
    +      removeExecutor(taskId, SlaveLost(reason))
    +      slaves(slaveId).taskIDs.remove(taskId)
    --- End diff --
    
    You're right that memory-wise it's not a big loss. But I prefer clean code. 
For instance, what's the meaning of having a Slave record for a host that 
doesn't run any tasks? Can this become a source of confusion down the road? 
Since it seems that it's not that complex to clean up, I'd go for it now.
    
    ```
    def removeTask(slave: Slave, taskId: String) = {
        slave.taskIDs.remove(taskId)
        if (slave.taskIDs.isEmpty) {
          slaves.remove(slaveId)
        }
      }
    ```
    
    In fact, this method may go inside `Slave`, who could properly encapsulate 
`taskIDs`. It may even be an inner class, so it can update `slaves`. Unless I'm 
missing something, we're talking about two lines of code.


---
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]

Reply via email to