caishunfeng commented on code in PR #16873:
URL:
https://github.com/apache/dolphinscheduler/pull/16873#discussion_r1889480993
##########
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:
If we add another coordintor, will all distributed services be executed on
this one active master? It seems the Master HA but not some logic coordinator
HA, I'm not sure if this adjustment will cause one active master to be busy
while others are idle.
```
public class MasterCoordinator extends AbstractHAServer {
private final ITaskGroupCoordinator taskGroupCoordinator;
}
```
--
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]