You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by we...@apache.org on 2022/02/14 14:55:33 UTC

[dolphinscheduler] branch 2.0.4-prepare updated: Fix deadlock in master/worker caused by close method (#8361)

This is an automated email from the ASF dual-hosted git repository.

wenjun pushed a commit to branch 2.0.4-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/2.0.4-prepare by this push:
     new de476ed  Fix deadlock in master/worker caused by close method (#8361)
de476ed is described below

commit de476edc38d7ef7cd68c8f3c5a23406ddfc424b8
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Mon Feb 14 22:55:24 2022 +0800

    Fix deadlock in master/worker caused by close method (#8361)
---
 .../org/apache/dolphinscheduler/server/master/MasterServer.java  | 9 +++++----
 .../org/apache/dolphinscheduler/server/worker/WorkerServer.java  | 8 ++++----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
index 179b702..bf4e3c0 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
@@ -229,16 +229,17 @@ public class MasterServer implements IStoppable {
             // close spring Context and will invoke method with @PreDestroy annotation to destory beans. like ServerNodeManager,HostManager,TaskResponseService,CuratorZookeeperClient,etc
             springApplicationContext.close();
             logger.info("springApplicationContext close");
-        } catch (Exception e) {
-            logger.error("master server stop exception ", e);
-        } finally {
             try {
                 // thread sleep 60 seconds for quietly stop
                 Thread.sleep(60000L);
             } catch (Exception e) {
                 logger.warn("thread sleep exception ", e);
             }
-            System.exit(1);
+            // Since close will be executed in hook, so we can't use System.exit here.
+            Runtime.getRuntime().halt(0);
+        } catch (Exception e) {
+            logger.error("master server stop exception ", e);
+            Runtime.getRuntime().halt(1);
         }
     }
 
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java
index ff0067c..f1fe3b1 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java
@@ -200,16 +200,16 @@ public class WorkerServer implements IStoppable {
             this.alertClientService.close();
             this.springApplicationContext.close();
             logger.info("springApplicationContext close");
-        } catch (Exception e) {
-            logger.error("worker server stop exception ", e);
-        } finally {
             try {
                 // thread sleep 60 seconds for quietly stop
                 Thread.sleep(60000L);
             } catch (Exception e) {
                 logger.warn("thread sleep exception ", e);
             }
-            System.exit(1);
+            Runtime.getRuntime().halt(0);
+        } catch (Exception e) {
+            logger.error("worker server stop exception ", e);
+            Runtime.getRuntime().halt(1);
         }
     }