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

zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 738da1cda3 [Fix][Master] Fix Potential danger in the event of a worker 
failover (#15689)
738da1cda3 is described below

commit 738da1cda3731543cdec61c249a051fbc99da929
Author: ZhongJinHacker <[email protected]>
AuthorDate: Mon Mar 11 21:50:21 2024 +0800

    [Fix][Master] Fix Potential danger in the event of a worker failover 
(#15689)
    
    * clean unused import
    
    * fix style check
    
    * fix when path is null or empty, it will cause serverhost is null,
    
    * fix UT test (#15684)
    
    * [Fix-15639] parameterPassing is null case NPE (#15678)
    
    Co-authored-by: caishunfeng <[email protected]>
    
    * fix  when path is null or empty, it will cause serverhost is null,
---
 .../master/registry/MasterRegistryClient.java      | 23 ++++++++++++----------
 .../master/registry/MasterRegistryClientTest.java  |  6 ++++++
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git 
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
 
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
index 99731bbf0e..4468af495a 100644
--- 
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
+++ 
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
@@ -131,17 +131,20 @@ public class MasterRegistryClient implements 
AutoCloseable {
     public void removeWorkerNodePath(String path, RegistryNodeType nodeType, 
boolean failover) {
         log.info("{} node deleted : {}", nodeType, path);
         try {
-            String serverHost = null;
-            if (!StringUtils.isEmpty(path)) {
-                serverHost = registryClient.getHostByEventDataPath(path);
-                if (StringUtils.isEmpty(serverHost)) {
-                    log.error("server down error: unknown path: {}", path);
-                    return;
-                }
-                if (!registryClient.exists(path)) {
-                    log.info("path: {} not exists", path);
-                }
+            if (StringUtils.isEmpty(path)) {
+                log.error("server down error: node empty path: {}, 
nodeType:{}", path, nodeType);
+                return;
             }
+
+            String serverHost = registryClient.getHostByEventDataPath(path);
+            if (StringUtils.isEmpty(serverHost)) {
+                log.error("server down error: unknown path: {}", path);
+                return;
+            }
+            if (!registryClient.exists(path)) {
+                log.info("path: {} not exists", path);
+            }
+
             // failover server
             if (failover) {
                 failoverService.failoverServerWhenDown(serverHost, nodeType);
diff --git 
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java
 
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java
index 133ed4e4ff..2ff2b873e1 100644
--- 
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java
+++ 
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java
@@ -103,4 +103,10 @@ public class MasterRegistryClientTest {
         // Cannot mock static methods
         masterRegistryClient.removeWorkerNodePath("/path", 
RegistryNodeType.WORKER, true);
     }
+
+    @Test
+    public void removeWorkNodePathTest() {
+        masterRegistryClient.removeWorkerNodePath("", RegistryNodeType.WORKER, 
true);
+        masterRegistryClient.removeWorkerNodePath(null, 
RegistryNodeType.WORKER, true);
+    }
 }

Reply via email to