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

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 68859c13a11 branch-3.1: [improve](cloud) make meta_service_endpoint 
configurable #51748 (#52154)
68859c13a11 is described below

commit 68859c13a1173be3644f89fafd0566d05a70906b
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jun 24 18:45:20 2025 +0800

    branch-3.1: [improve](cloud) make meta_service_endpoint configurable #51748 
(#52154)
    
    Cherry-picked from #51748
    
    Co-authored-by: HonestManXin <[email protected]>
---
 be/src/agent/heartbeat_server.cpp                  | 31 +++++++++++++++++-----
 be/src/cloud/cloud_meta_mgr.cpp                    |  5 +---
 .../main/java/org/apache/doris/common/Config.java  |  4 +--
 .../java/org/apache/doris/common/ConfigBase.java   | 16 +++++++++++
 .../apache/doris/cloud/rpc/MetaServiceClient.java  |  8 ++----
 .../java/org/apache/doris/system/HeartbeatMgr.java |  3 +++
 6 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/be/src/agent/heartbeat_server.cpp 
b/be/src/agent/heartbeat_server.cpp
index 0cb6bea2220..498315f2bad 100644
--- a/be/src/agent/heartbeat_server.cpp
+++ b/be/src/agent/heartbeat_server.cpp
@@ -25,6 +25,7 @@
 #include <memory>
 #include <ostream>
 #include <string>
+#include <vector>
 
 #include "cloud/cloud_tablet_mgr.h"
 #include "cloud/config.h"
@@ -260,16 +261,34 @@ Status HeartbeatServer::_heartbeat(const TMasterInfo& 
master_info) {
                       << " " << st;
         }
 
-        if (master_info.meta_service_endpoint != config::meta_service_endpoint 
&&
-            config::enable_meta_service_endpoint_consistency_check) {
+        if (master_info.meta_service_endpoint != 
config::meta_service_endpoint) {
             LOG(WARNING) << "Detected mismatch in meta_service_endpoint 
configuration between FE "
                             "and BE. "
                          << "FE meta_service_endpoint: " << 
master_info.meta_service_endpoint
                          << ", BE meta_service_endpoint: " << 
config::meta_service_endpoint;
-            return Status::InvalidArgument<false>(
-                    "fe and be do not work in same mode or 
meta_service_endpoint mismatch,"
-                    "fe meta_service_endpoint: {}, be meta_service_endpoint: 
{}",
-                    master_info.meta_service_endpoint, 
config::meta_service_endpoint);
+            std::vector<std::string> old_endpoints =
+                    doris::split(config::meta_service_endpoint, ",");
+            std::vector<std::string> new_endpoints =
+                    doris::split(master_info.meta_service_endpoint, ",");
+            auto has_intersection = false;
+            for (auto endpoint : new_endpoints) {
+                if (std::find(old_endpoints.begin(), old_endpoints.end(), 
endpoint) !=
+                    old_endpoints.end()) {
+                    has_intersection = true;
+                }
+            }
+            if (has_intersection) {
+                auto st = config::set_config("meta_service_endpoint",
+                                             
master_info.meta_service_endpoint, true);
+                LOG(INFO) << "change config meta_service_endpoint to "
+                          << master_info.meta_service_endpoint << " " << st;
+            }
+            if (!has_intersection && 
config::enable_meta_service_endpoint_consistency_check) {
+                return Status::InvalidArgument<false>(
+                        "fe and be do not work in same mode or 
meta_service_endpoint mismatch,"
+                        "fe meta_service_endpoint: {}, be 
meta_service_endpoint: {}",
+                        master_info.meta_service_endpoint, 
config::meta_service_endpoint);
+            }
         }
     }
 
diff --git a/be/src/cloud/cloud_meta_mgr.cpp b/be/src/cloud/cloud_meta_mgr.cpp
index 26cd88bcfe0..e811297beea 100644
--- a/be/src/cloud/cloud_meta_mgr.cpp
+++ b/be/src/cloud/cloud_meta_mgr.cpp
@@ -187,15 +187,12 @@ public:
 
         long deadline = now;
         // connection age only works without list endpoint.
-        if (!is_meta_service_endpoint_list() &&
-            config::meta_service_connection_age_base_seconds > 0) {
+        if (config::meta_service_connection_age_base_seconds > 0) {
             std::default_random_engine rng(static_cast<uint32_t>(now));
             std::uniform_int_distribution<> uni(
                     config::meta_service_connection_age_base_seconds,
                     config::meta_service_connection_age_base_seconds * 2);
             deadline = now + 
duration_cast<milliseconds>(seconds(uni(rng))).count();
-        } else {
-            deadline = LONG_MAX;
         }
 
         // Last one WIN
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index bc07f1027fe..8a66c885291 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -3033,7 +3033,7 @@ public class Config extends ConfigBase {
      * If you want to access a group of meta services, separated the endpoints 
by comma,
      * like "host-1:port,host-2:port".
      */
-    @ConfField
+    @ConfField(mutable = true, callback = 
CommaSeparatedIntersectConfHandler.class)
     public static String meta_service_endpoint = "";
 
     @ConfField(mutable = true)
@@ -3054,8 +3054,6 @@ public class Config extends ConfigBase {
 
     // A connection will expire after a random time during [base, 2*base), so 
that the FE
     // has a chance to connect to a new RS. Set zero to disable it.
-    //
-    // It only works if the meta_service_endpoint is not point to a group of 
meta services.
     @ConfField(mutable = true)
     public static int meta_service_connection_age_base_minutes = 5;
 
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/ConfigBase.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/ConfigBase.java
index 71819217925..ceacc7b14bc 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/ConfigBase.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/ConfigBase.java
@@ -20,6 +20,7 @@ package org.apache.doris.common;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -36,6 +37,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -79,6 +81,20 @@ public class ConfigBase {
         }
     }
 
+    static class CommaSeparatedIntersectConfHandler implements ConfHandler {
+        @Override
+        public void handle(Field field, String newVal) throws Exception {
+            String oldVal = String.valueOf(field.get(null));
+            Set<String> oldSets = Sets.newHashSet(oldVal.split(","));
+            Set<String> newSets = Sets.newHashSet(newVal.split(","));
+            if (!oldSets.removeAll(newSets)) {
+                throw new ConfigException("Config '" + field.getName()
+                    + "' must have intersection between the configs");
+            }
+            setConfigField(field, newVal);
+        }
+    }
+
     private static String confFile;
     private static String customConfFile;
     public static Class<? extends ConfigBase> confClass;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/rpc/MetaServiceClient.java 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/rpc/MetaServiceClient.java
index 048d8ab93df..f17625a89ea 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/cloud/rpc/MetaServiceClient.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/rpc/MetaServiceClient.java
@@ -48,7 +48,6 @@ public class MetaServiceClient {
     private final MetaServiceGrpc.MetaServiceBlockingStub blockingStub;
     private final ManagedChannel channel;
     private final long expiredAt;
-    private final boolean isMetaServiceEndpointList;
     private Random random = new Random();
 
     static {
@@ -64,10 +63,8 @@ public class MetaServiceClient {
     public MetaServiceClient(String address) {
         this.address = address;
 
-        isMetaServiceEndpointList = address.contains(",");
-
         String target = address;
-        if (isMetaServiceEndpointList) {
+        if (address.contains(",")) {
             target = MetaServiceListResolverProvider.MS_LIST_SCHEME_PREFIX + 
address;
         }
 
@@ -87,8 +84,7 @@ public class MetaServiceClient {
 
     private long connectionAgeExpiredAt() {
         long connectionAgeBase = 
Config.meta_service_connection_age_base_minutes;
-        // Disable connection age if the endpoint is a list.
-        if (!isMetaServiceEndpointList && connectionAgeBase > 1) {
+        if (connectionAgeBase > 0) {
             long base = TimeUnit.MINUTES.toMillis(connectionAgeBase);
             long now = System.currentTimeMillis();
             long rand = random.nextLong() % base;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java 
b/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
index 036efd05d79..c839222af5e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/system/HeartbeatMgr.java
@@ -109,6 +109,9 @@ public class HeartbeatMgr extends MasterDaemon {
      */
     @Override
     protected void runAfterCatalogReady() {
+        if (Config.isCloudMode() && masterInfo.get() != null) {
+            
masterInfo.get().setMetaServiceEndpoint(Config.meta_service_endpoint);
+        }
         // Get feInfos of previous iteration.
         List<TFrontendInfo> feInfos = Env.getCurrentEnv().getFrontendInfos();
         List<Future<HeartbeatResponse>> hbResponses = Lists.newArrayList();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to