You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2022/07/01 03:12:42 UTC

[doris] branch master updated: [bugfix](fe) fix add follower failed due to conflict socket . (#10429)

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

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new d0b757c03a [bugfix](fe) fix add follower failed due to conflict socket . (#10429)
d0b757c03a is described below

commit d0b757c03a04b38150aa5b050cc4c2cd2367b373
Author: Lei Zhang <10...@qq.com>
AuthorDate: Fri Jul 1 11:12:36 2022 +0800

    [bugfix](fe) fix add follower failed due to conflict socket . (#10429)
---
 .../main/java/org/apache/doris/catalog/Catalog.java   |  4 +++-
 .../src/main/java/org/apache/doris/ha/BDBHA.java      | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
index 534bb7fad0..b1818105ff 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -2464,10 +2464,12 @@ public class Catalog {
 
             fe = new Frontend(role, nodeName, host, editLogPort);
             frontends.put(nodeName, fe);
+            BDBHA bdbha = (BDBHA) haProtocol;
             if (role == FrontendNodeType.FOLLOWER || role == FrontendNodeType.REPLICA) {
-                ((BDBHA) getHaProtocol()).addHelperSocket(host, editLogPort);
+                bdbha.addHelperSocket(host, editLogPort);
                 helperNodes.add(Pair.create(host, editLogPort));
             }
+            bdbha.removeConflictNodeIfExist(host, editLogPort);
             editLog.logAddFrontend(fe);
         } finally {
             unlock();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/ha/BDBHA.java b/fe/fe-core/src/main/java/org/apache/doris/ha/BDBHA.java
index e6fbcd3183..22d15373d8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/ha/BDBHA.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/ha/BDBHA.java
@@ -221,4 +221,23 @@ public class BDBHA implements HAProtocol {
             LOG.info("add {}:{} to helper sockets", ip, port);
         }
     }
+
+    public void removeConflictNodeIfExist(String host, int port) {
+        ReplicationGroupAdmin replicationGroupAdmin = environment.getReplicationGroupAdmin();
+        if (replicationGroupAdmin == null) {
+            return;
+        }
+
+        List<String> conflictNodes = Lists.newArrayList();
+        Set<ReplicationNode> replicationNodes = replicationGroupAdmin.getGroup().getElectableNodes();
+        for (ReplicationNode replicationNode : replicationNodes) {
+            if (replicationNode.getHostName().equals(host) && replicationNode.getPort() == port) {
+                conflictNodes.add(replicationNode.getName());
+            }
+        }
+
+        for (String conflictNode : conflictNodes) {
+            removeElectableNode(conflictNode);
+        }
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org