diff --git a/core/src/main/scala/org/apache/spark/deploy/worker/WorkerWatcher.scala b/core/src/main/scala/org/apache/spark/deploy/worker/WorkerWatcher.scala index efffc9f23c4cc..b7a5728dd00d5 100644 --- a/core/src/main/scala/org/apache/spark/deploy/worker/WorkerWatcher.scala +++ b/core/src/main/scala/org/apache/spark/deploy/worker/WorkerWatcher.scala @@ -54,8 +54,12 @@ private[spark] class WorkerWatcher( if (isTesting) { isShutDown = true } else if (isChildProcessStopping.compareAndSet(false, true)) { - // SPARK-35714: avoid the duplicate call of `System.exit` to avoid the dead lock - System.exit(-1) + // SPARK-35714: avoid the duplicate call of `System.exit` to avoid the dead lock. + // Same as SPARK-14180, we should run `System.exit` in a separate thread to avoid + // dead lock since `System.exit` will trigger the shutdown hook of `executor.stop`. + new Thread("WorkerWatcher-exit-executor") { + override def run(): Unit = System.exit(-1) + }.start() } override def receive: PartialFunction[Any, Unit] = {