Browse Source

fix dead server cannot stop (#6046)

Wenjun Ruan 3 years ago
parent
commit
839d6054ee

+ 5 - 6
dolphinscheduler-registry-plugin/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java

@@ -47,6 +47,7 @@ import org.apache.curator.framework.recipes.locks.InterProcessMutex;
 import org.apache.curator.retry.ExponentialBackoffRetry;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.data.ACL;
 
@@ -195,12 +196,7 @@ public class ZookeeperRegistry implements Registry {
 
     @Override
     public void remove(String key) {
-
-        try {
-            client.delete().deletingChildrenIfNeeded().forPath(key);
-        } catch (Exception e) {
-            throw new RegistryException("zookeeper remove error", e);
-        }
+        delete(key);
     }
 
     @Override
@@ -269,6 +265,9 @@ public class ZookeeperRegistry implements Registry {
             client.delete()
                     .deletingChildrenIfNeeded()
                     .forPath(nodePath);
+        } catch (KeeperException.NoNodeException ignore) {
+            // the node is not exist, we can believe the node has been removed
+
         } catch (Exception e) {
             throw new RegistryException("zookeeper delete key error", e);
         }

+ 1 - 0
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java

@@ -181,6 +181,7 @@ public class WorkerServer implements IStoppable {
             this.nettyRemotingServer.close();
             this.workerRegistryClient.unRegistry();
             this.alertClientService.close();
+            this.springApplicationContext.close();
         } catch (Exception e) {
             logger.error("worker server stop exception ", e);
         }

+ 1 - 0
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/RetryReportTaskStatusThread.java

@@ -49,6 +49,7 @@ public class RetryReportTaskStatusThread implements Runnable {
 
     public void start(){
         Thread thread = new Thread(this,"RetryReportTaskStatusThread");
+        thread.setDaemon(true);
         thread.start();
     }
 

+ 1 - 0
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerManagerThread.java

@@ -123,6 +123,7 @@ public class WorkerManagerThread implements Runnable {
 
     public void start() {
         Thread thread = new Thread(this, this.getClass().getName());
+        thread.setDaemon(true);
         thread.start();
     }