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 2023/11/03 06:33:13 UTC
(doris) branch master updated: [fix](fe) Add/remove frontends after updating BEBJE (#26313)
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 a4637e44622 [fix](fe) Add/remove frontends after updating BEBJE (#26313)
a4637e44622 is described below
commit a4637e446223fde585e0c746092135210d8b0746
Author: walter <w4...@gmail.com>
AuthorDate: Fri Nov 3 14:33:06 2023 +0800
[fix](fe) Add/remove frontends after updating BEBJE (#26313)
To ensure exception safety, adding or removing frontends in memory
should execute after removing the electable nodes (might throw
exceptions)
---
.../main/java/org/apache/doris/catalog/Env.java | 32 ++++++++++++++--------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 29122a1042b..1cbdcc12a19 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -2678,16 +2678,20 @@ public class Env {
throw new DdlException("frontend name already exists " + nodeName + ". Try again");
}
- fe = new Frontend(role, nodeName, host, editLogPort);
- LOG.info("add frontend: {}", fe);
-
- frontends.put(nodeName, fe);
BDBHA bdbha = (BDBHA) haProtocol;
+ bdbha.removeConflictNodeIfExist(host, editLogPort);
+ int targetFollowerCount = getFollowerCount() + 1;
if (role == FrontendNodeType.FOLLOWER || role == FrontendNodeType.REPLICA) {
helperNodes.add(new HostInfo(host, editLogPort));
- bdbha.addUnReadyElectableNode(nodeName, getFollowerCount());
+ bdbha.addUnReadyElectableNode(nodeName, targetFollowerCount);
}
- bdbha.removeConflictNodeIfExist(host, editLogPort);
+
+ // Only add frontend after removing the conflict nodes, to ensure the exception safety.
+ fe = new Frontend(role, nodeName, host, editLogPort);
+ frontends.put(nodeName, fe);
+
+ LOG.info("add frontend: {}", fe);
+
editLog.logAddFrontend(fe);
} finally {
unlock();
@@ -2748,17 +2752,21 @@ public class Env {
.getHostPortInAccessibleFormat(host, port) + "]");
}
- LOG.info("remove frontend: {}", fe);
-
- frontends.remove(fe.getNodeName());
- removedFrontends.add(fe.getNodeName());
-
+ int targetFollowerCount = getFollowerCount() - 1;
if (fe.getRole() == FrontendNodeType.FOLLOWER || fe.getRole() == FrontendNodeType.REPLICA) {
haProtocol.removeElectableNode(fe.getNodeName());
removeHelperNode(host, port);
BDBHA ha = (BDBHA) haProtocol;
- ha.removeUnReadyElectableNode(fe.getNodeName(), getFollowerCount());
+ ha.removeUnReadyElectableNode(fe.getNodeName(), targetFollowerCount);
}
+
+ LOG.info("remove frontend: {}", fe);
+
+ // Only remove frontend after removing the electable node success, to ensure the
+ // exception safety.
+ frontends.remove(fe.getNodeName());
+ removedFrontends.add(fe.getNodeName());
+
editLog.logRemoveFrontend(fe);
} finally {
unlock();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org