From b0370dd0acd830a74b643084e1100ddad534f489 Mon Sep 17 00:00:00 2001 From: HHoflittlefish777 <77738092+HHoflittlefish777@users.noreply.github.com> Date: Sat, 9 Dec 2023 05:09:52 +0800 Subject: [PATCH] [improve](group_commit) optimize group commit select be logic #28190 Group commit choose be always first no decommissioned be in all be. Choose be with selectBackendIdsByPolicy like common stream load and do not choose decommissioned be may be better. --- .../apache/doris/httpv2/rest/LoadAction.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java index 32757f2894f714..21778862166084 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java @@ -335,9 +335,17 @@ private Object executeStreamLoad2PC(HttpServletRequest request, String db) { private TNetworkAddress selectRedirectBackend(String clusterName, boolean groupCommit) throws LoadException { Backend backend = null; BeSelectionPolicy policy = null; + String qualifiedUser = ConnectContext.get().getQualifiedUser(); + Set userTags = Env.getCurrentEnv().getAuth().getResourceTags(qualifiedUser); + policy = new BeSelectionPolicy.Builder() + .addTags(userTags) + .needLoadAvailable().build(); + List backendIds = Env.getCurrentSystemInfo().selectBackendIdsByPolicy(policy, 1); + if (backendIds.isEmpty()) { + throw new LoadException(SystemInfoService.NO_BACKEND_LOAD_AVAILABLE_MSG + ", policy: " + policy); + } if (groupCommit) { - List allBackendIds = Env.getCurrentSystemInfo().getAllBackendIds(true); - for (Long backendId : allBackendIds) { + for (Long backendId : backendIds) { Backend candidateBe = Env.getCurrentSystemInfo().getBackend(backendId); if (!candidateBe.isDecommissioned()) { backend = candidateBe; @@ -345,15 +353,6 @@ private TNetworkAddress selectRedirectBackend(String clusterName, boolean groupC } } } else { - String qualifiedUser = ConnectContext.get().getQualifiedUser(); - Set userTags = Env.getCurrentEnv().getAuth().getResourceTags(qualifiedUser); - policy = new BeSelectionPolicy.Builder() - .addTags(userTags) - .needLoadAvailable().build(); - List backendIds = Env.getCurrentSystemInfo().selectBackendIdsByPolicy(policy, 1); - if (backendIds.isEmpty()) { - throw new LoadException(SystemInfoService.NO_BACKEND_LOAD_AVAILABLE_MSG + ", policy: " + policy); - } backend = Env.getCurrentSystemInfo().getBackend(backendIds.get(0)); } if (backend == null) {