kevin85421 commented on code in PR #37411:
URL: https://github.com/apache/spark/pull/37411#discussion_r943105027


##########
core/src/main/scala/org/apache/spark/HeartbeatReceiver.scala:
##########
@@ -199,41 +242,137 @@ private[spark] class HeartbeatReceiver(sc: SparkContext, 
clock: Clock)
     removeExecutor(executorRemoved.executorId)
   }
 
+  private def killExecutor(executorId: String, timeout: Long): Unit = {
+    logWarning(s"Removing executor $executorId with no recent heartbeats: " +
+      s"${timeout} ms exceeds timeout $executorTimeoutMs ms")
+    killExecutorThread.submit(new Runnable {
+      override def run(): Unit = Utils.tryLogNonFatalError {
+        // Note: we want to get an executor back after expiring this one,
+        // so do not simply call `sc.killExecutor` here (SPARK-8119)
+        sc.killAndReplaceExecutor(executorId)
+        // SPARK-27348: in case of the executors which are not gracefully shut 
down,
+        // we should remove lost executors from CoarseGrainedSchedulerBackend 
manually
+        // here to guarantee two things:
+        // 1) explicitly remove executor information from 
CoarseGrainedSchedulerBackend for
+        //    a lost executor instead of waiting for disconnect message
+        // 2) call scheduler.executorLost() underlying to fail any tasks 
assigned to
+        //    those executors to avoid app hang
+        sc.schedulerBackend match {
+          case backend: CoarseGrainedSchedulerBackend =>
+            val isStandalone = backend.isInstanceOf[StandaloneSchedulerBackend]
+            backend.driverEndpoint.send(RemoveExecutor(executorId,
+              ExecutorProcessLost(
+                s"Executor heartbeat timed out after ${timeout} ms",
+                causedByApp = !checkWorkerLastHeartbeat || !isStandalone)))

Review Comment:
   I am not sure the precise definition about "executor/jvm hangs" you mention 
above. Thus, I made some assumptions to explain.
   
   Assumptions:
   (1) Executor cannot send/reply any message when "executor hangs", and JVM 
does not crash.
   => The executor loss will be detected by HeartbeatReceiver on driver
   
   (2) Executor can send/reply messages when "executor hangs", and JVM does not 
crash.
   => Cannot be detected.
   
   (3) JVM crashes
   => The event will be detected by driver.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to