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


##########
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:
   As the issue avoid to use lock, but it's actually still using lock, what's 
the difference? 



-- 
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