ruanwenjun commented on code in PR #16873:
URL: 
https://github.com/apache/dolphinscheduler/pull/16873#discussion_r1889987162


##########
dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/ha/AbstractHAServer.java:
##########
@@ -78,21 +83,30 @@ public boolean isActive() {
     @Override
     public boolean participateElection() {
         final String electionLock = selectorPath + "-lock";
-        try {
-            if (registry.acquireLock(electionLock)) {
-                if (!registry.exists(selectorPath)) {
-                    registry.put(selectorPath, serverIdentify, true);
-                    return true;
+        // If meet exception during participate election, will retry.
+        // This can avoid the situation that the server is not elected as 
leader due to network jitter.
+        for (int i = 0; i < DEFAULT_MAX_RETRY_TIMES; i++) {
+            try {
+                try {
+                    if (registry.acquireLock(electionLock)) {
+                        if (!registry.exists(selectorPath)) {
+                            registry.put(selectorPath, serverIdentify, true);
+                            return true;
+                        }
+                        return 
serverIdentify.equals(registry.get(selectorPath));
+                    }
+                    return false;
+                } finally {
+                    registry.releaseLock(electionLock);
                 }

Review Comment:
   Yes, the coordinator master shouldn't do a lot of business work, it would be 
great if it only deals with coordination work. At our usage case, the 
coordinator master will only coordinate task group, deal with serial wait this 
will not affect even though the master is busy, these work will not be affect.
   
   BTW, after fixing a lot of memory leak/thread leak bug, I haven't found a 
master status change to BUSY in our cluster, currently, there is basically no 
heavy workload in the masters, most case is db busy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to