agrawaldevesh commented on a change in pull request #29014:
URL: https://github.com/apache/spark/pull/29014#discussion_r459824554



##########
File path: 
core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala
##########
@@ -939,12 +941,40 @@ private[spark] class TaskSchedulerImpl(
 
   override def executorDecommission(
       executorId: String, decommissionInfo: ExecutorDecommissionInfo): Unit = {
+    synchronized {
+      // The scheduler can get multiple decommission updates from multiple 
sources,
+      // and some of those can have isHostDecommissioned false. We merge them 
such that
+      // if we heard isHostDecommissioned ever true, then we keep that one 
since it is
+      // most likely coming from the cluster manager and thus authoritative
+      val oldDecomInfo = executorsPendingDecommission.get(executorId)
+      if (oldDecomInfo.isEmpty || !oldDecomInfo.get.isHostDecommissioned) {
+        executorsPendingDecommission(executorId) = decommissionInfo
+      }
+    }
     rootPool.executorDecommission(executorId)
     backend.reviveOffers()
   }
 
-  override def executorLost(executorId: String, reason: ExecutorLossReason): 
Unit = {
+  override def getExecutorDecommissionInfo(executorId: String)
+    : Option[ExecutorDecommissionInfo] = synchronized {
+      executorsPendingDecommission.get(executorId)
+  }
+
+  override def executorLost(executorId: String, givenReason: 
ExecutorLossReason): Unit = {
     var failedExecutor: Option[String] = None
+    val reason = givenReason match {
+      // Handle executor process loss due to decommissioning
+      case ExecutorProcessLost(message, workerLost, causedByApp) =>
+        val executorDecommissionInfo = getExecutorDecommissionInfo(executorId)
+        ExecutorProcessLost(
+          message,
+          // Also mark the worker lost if we know that the host was 
decommissioned
+          workerLost || 
executorDecommissionInfo.exists(_.isHostDecommissioned),

Review comment:
       Right !. But Executor is only removed from 
`executorsPendingDecommission` in `TaskSchedulerImpl.removeExecutor`. I believe 
it would be a bug for an executor to be re-registered with the same 
`executorId` ?
   
   @viirya please correct my understanding if that is not the case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to