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

kirs 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 7e90e665f9b [fix](cloud) Fix constant folding for requests sent to BE 
without dis… (#42865)
7e90e665f9b is described below

commit 7e90e665f9b331b30e2cbd2994e1f1086cf6a4bb
Author: deardeng <565620...@qq.com>
AuthorDate: Fri Nov 1 21:44:36 2024 +0800

    [fix](cloud) Fix constant folding for requests sent to BE without dis… 
(#42865)
    
    …tinguishing clusters
    
    ## Proposed changes
    
    Issue Number: close #xxx
    
    <!--Describe your changes.-->
    
    replace function getAllBackendIds by getBackendsByCurrentCluster
---
 .../rules/expression/rules/FoldConstantRuleOnBE.java      |  2 +-
 .../java/org/apache/doris/rewrite/FoldConstantsRule.java  |  2 +-
 .../org/apache/doris/service/FrontendServiceImpl.java     |  4 ++--
 .../java/org/apache/doris/system/SystemInfoService.java   | 15 +++++++++++++--
 .../doris/tablefunction/LocalTableValuedFunction.java     |  2 +-
 5 files changed, 18 insertions(+), 7 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
index dedd1b35bd7..64f7c2784f7 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
@@ -270,7 +270,7 @@ public class FoldConstantRuleOnBE implements 
ExpressionPatternRuleFactory {
             Map<String, Expression> constMap, ConnectContext context) {
         Map<String, Expression> resultMap = new HashMap<>();
         try {
-            List<Long> backendIds = 
Env.getCurrentSystemInfo().getAllBackendIds(true);
+            List<Long> backendIds = 
Env.getCurrentSystemInfo().getAllBackendByCurrentCluster(true);
             if (backendIds.isEmpty()) {
                 throw new UserException("No alive backends");
             }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FoldConstantsRule.java 
b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FoldConstantsRule.java
index d86d8c22564..6275cb9bb84 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FoldConstantsRule.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FoldConstantsRule.java
@@ -361,7 +361,7 @@ public class FoldConstantsRule implements ExprRewriteRule {
         TNetworkAddress brpcAddress = null;
         Map<String, Map<String, Expr>> resultMap = new HashMap<>();
         try {
-            List<Long> backendIds = 
Env.getCurrentSystemInfo().getAllBackendIds(true);
+            List<Long> backendIds = 
Env.getCurrentSystemInfo().getAllBackendByCurrentCluster(true);
             if (backendIds.isEmpty()) {
                 throw new LoadException("Failed to get all partitions. No 
alive backends");
             }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java 
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index cd1af82563d..e3d543d9111 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -3495,7 +3495,7 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
         // build nodes
         List<TNodeInfo> nodeInfos = Lists.newArrayList();
         SystemInfoService systemInfoService = Env.getCurrentSystemInfo();
-        for (Long id : systemInfoService.getAllBackendIds(false)) {
+        for (Long id : systemInfoService.getAllBackendByCurrentCluster(false)) 
{
             Backend backend = systemInfoService.getBackend(id);
             nodeInfos.add(new TNodeInfo(backend.getId(), 0, backend.getHost(), 
backend.getBrpcPort()));
         }
@@ -3704,7 +3704,7 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
         // build nodes
         List<TNodeInfo> nodeInfos = Lists.newArrayList();
         SystemInfoService systemInfoService = Env.getCurrentSystemInfo();
-        for (Long id : systemInfoService.getAllBackendIds(false)) {
+        for (Long id : systemInfoService.getAllBackendByCurrentCluster(false)) 
{
             Backend backend = systemInfoService.getBackend(id);
             nodeInfos.add(new TNodeInfo(backend.getId(), 0, backend.getHost(), 
backend.getBrpcPort()));
         }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java 
b/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java
index 69216dd4d13..447dc3457ae 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java
@@ -164,7 +164,7 @@ public class SystemInfoService {
     public static TPaloNodesInfo createAliveNodesInfo() {
         TPaloNodesInfo nodesInfo = new TPaloNodesInfo();
         SystemInfoService systemInfoService = Env.getCurrentSystemInfo();
-        for (Long id : systemInfoService.getAllBackendIds(true /*need 
alive*/)) {
+        for (Long id : systemInfoService.getAllBackendByCurrentCluster(true)) {
             Backend backend = systemInfoService.getBackend(id);
             nodesInfo.addToNodes(new TNodeInfo(backend.getId(), 0, 
backend.getHost(), backend.getBrpcPort()));
         }
@@ -363,11 +363,22 @@ public class SystemInfoService {
     public int getBackendsNumber(boolean needAlive) {
         int beNumber = 
ConnectContext.get().getSessionVariable().getBeNumberForTest();
         if (beNumber < 0) {
-            beNumber = getAllBackendIds(needAlive).size();
+            beNumber = getAllBackendByCurrentCluster(needAlive).size();
         }
         return beNumber;
     }
 
+    public List<Long> getAllBackendByCurrentCluster(boolean needAlive) {
+        try {
+            return getBackendsByCurrentCluster()
+                .values().stream().filter(be -> !needAlive || be.isAlive())
+                .map(Backend::getId).collect(Collectors.toList());
+        } catch (AnalysisException e) {
+            LOG.warn("failed to get backends by Current Cluster", e);
+            return Lists.newArrayList();
+        }
+    }
+
     public List<Long> getAllBackendIds(boolean needAlive) {
         ImmutableMap<Long, Backend> idToBackend = 
getAllClusterBackendsNoException();
         List<Long> backendIds = Lists.newArrayList(idToBackend.keySet());
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/LocalTableValuedFunction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/LocalTableValuedFunction.java
index df1bf6b61b2..32f76b233fa 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/LocalTableValuedFunction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/LocalTableValuedFunction.java
@@ -96,7 +96,7 @@ public class LocalTableValuedFunction extends 
ExternalFileTableValuedFunction {
             backendIdForRequest = backendId;
         } else {
             Preconditions.checkState(sharedStorage);
-            List<Long> beIds = 
Env.getCurrentSystemInfo().getAllBackendIds(true);
+            List<Long> beIds = 
Env.getCurrentSystemInfo().getAllBackendByCurrentCluster(true);
             if (beIds.isEmpty()) {
                 throw new AnalysisException("No available backend");
             }


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

Reply via email to