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

    https://github.com/apache/spark/pull/8887#discussion_r42198351
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala ---
    @@ -459,46 +458,64 @@ private[spark] class TaskSchedulerImpl(
       }
     
       override def executorLost(executorId: String, reason: 
ExecutorLossReason): Unit = {
    -    var failedExecutor: Option[String] = None
    +    removeExecutor(executorId, reason)
    +  }
     
    -    synchronized {
    -      if (activeExecutorIds.contains(executorId)) {
    -        val hostPort = executorIdToHost(executorId)
    -        logError("Lost executor %s on %s: %s".format(executorId, hostPort, 
reason))
    -        removeExecutor(executorId, reason)
    -        failedExecutor = Some(executorId)
    +  /** Remove all information related to the executor. */
    +  private def removeExecutor(executorId: String, reason: 
ExecutorLossReason): Unit = {
    +    val wasActive = synchronized {
    +      if (activeExecutorIds.remove(executorId)) {
    +        val host = executorIdToHost(executorId)
    +        executorsByHost.get(host).foreach { execs =>
    +          execs -= executorId
    +          if (execs.isEmpty) {
    +            executorsByHost -= host
    +            for (rack <- getRackForHost(host); hosts <- 
hostsByRack.get(rack)) {
    +              hosts -= host
    +              if (hosts.isEmpty) {
    +                hostsByRack -= rack
    +              }
    +            }
    +          }
    +        }
    +        true
           } else {
    -         // We may get multiple executorLost() calls with different loss 
reasons. For example, one
    -         // may be triggered by a dropped connection from the slave while 
another may be a report
    -         // of executor termination from Mesos. We produce log messages 
for both so we eventually
    -         // report the termination reason.
    -         logError("Lost an executor " + executorId + " (already removed): 
" + reason)
    +        false
           }
         }
    -    // Call dagScheduler.executorLost without holding the lock on this to 
prevent deadlock
    -    if (failedExecutor.isDefined) {
    -      dagScheduler.executorLost(failedExecutor.get)
    +    if (wasActive) {
    --- End diff --
    
    need similar comment here: this must be called outside synchronized block 
to prevent potential deadlocks


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