From f12436cbb1e0968c407135f4f394fffff57049f3 Mon Sep 17 00:00:00 2001 From: casionone Date: Wed, 13 Dec 2023 20:49:45 +0800 Subject: [PATCH] fix bug when killTask may kill main thread --- .../spark/executor/SparkEngineConnExecutor.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/executor/SparkEngineConnExecutor.scala b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/executor/SparkEngineConnExecutor.scala index d94dafa9f7..95c18b3ca9 100644 --- a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/executor/SparkEngineConnExecutor.scala +++ b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/executor/SparkEngineConnExecutor.scala @@ -315,9 +315,14 @@ abstract class SparkEngineConnExecutor(val sc: SparkContext, id: Long) logger.info(s"thread isInterrupted:${thread.isInterrupted}") if (closeThreadEnable) { - logger.info(s"try to force stop thread:${thread.getName}") - // force to stop scala thread - Utils.tryAndWarn(thread.stop()) + val threadName = thread.getName + if (threadName.contains("Linkis-Default-Scheduler-Thread-")) { + logger.info(s"try to force stop thread:${threadName}") + // force to stop scala thread + Utils.tryAndWarn(thread.stop()) + } else { + logger.info(s"skip to force stop thread:${threadName}") + } } } killRunningTask()