This is an automated email from the ASF dual-hosted git repository. gavinchou pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new d7f3801b207 branch-3.0: [opt](cloud) Fix frequent rlock for SystemInfoService.getClusterXxx() #47203 (#47210) d7f3801b207 is described below commit d7f3801b2071a34c82028132816367e017275d70 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Mon Jan 20 09:53:45 2025 +0800 branch-3.0: [opt](cloud) Fix frequent rlock for SystemInfoService.getClusterXxx() #47203 (#47210) Cherry-picked from #47203 Co-authored-by: Gavin Chou <ga...@selectdb.com> --- .../doris/cloud/system/CloudSystemInfoService.java | 56 +++++++--------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java index 71260c51f23..15fa43dea09 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java @@ -492,12 +492,7 @@ public class CloudSystemInfoService extends SystemInfoService { } public boolean containClusterName(String clusterName) { - rlock.lock(); - try { - return clusterNameToId.containsKey(clusterName); - } finally { - rlock.unlock(); - } + return clusterNameToId.containsKey(clusterName); } @Override @@ -550,27 +545,17 @@ public class CloudSystemInfoService extends SystemInfoService { } public List<Backend> getBackendsByClusterName(final String clusterName) { - rlock.lock(); - try { - String clusterId = clusterNameToId.getOrDefault(clusterName, ""); - if (clusterId.isEmpty()) { - return new ArrayList<>(); - } - // copy a new List - return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); - } finally { - rlock.unlock(); + String clusterId = clusterNameToId.getOrDefault(clusterName, ""); + if (clusterId.isEmpty()) { + return new ArrayList<>(); } + // copy a new List + return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); } public List<Backend> getBackendsByClusterId(final String clusterId) { - rlock.lock(); - try { - // copy a new List - return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); - } finally { - rlock.unlock(); - } + // copy a new List + return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>())); } public String getClusterNameByBeAddr(String beEndpoint) { @@ -588,27 +573,18 @@ public class CloudSystemInfoService extends SystemInfoService { } public List<String> getCloudClusterIds() { - rlock.lock(); - try { - return new ArrayList<>(clusterIdToBackend.keySet()); - } finally { - rlock.unlock(); - } + return new ArrayList<>(clusterIdToBackend.keySet()); } public String getCloudStatusByName(final String clusterName) { - rlock.lock(); - try { - String clusterId = clusterNameToId.getOrDefault(clusterName, ""); - if (Strings.isNullOrEmpty(clusterId)) { - // for rename cluster or dropped cluster - LOG.warn("cant find clusterId by clusteName {}", clusterName); - return ""; - } - return getCloudStatusByIdNoLock(clusterId); - } finally { - rlock.unlock(); + String clusterId = clusterNameToId.getOrDefault(clusterName, ""); + if (Strings.isNullOrEmpty(clusterId)) { + // for rename cluster or dropped cluster + LOG.warn("cant find clusterId by clusteName {}", clusterName); + return ""; } + // It is safe to return a null/empty status string, the caller handles it properly + return getCloudStatusByIdNoLock(clusterId); } public String getCloudStatusById(final String clusterId) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org