Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 663fb7c

Browse filesBrowse files
gavinchouYour Name
authored and
Your Name
committed
[opt](cloud) Fix frequent rlock for SystemInfoService.getClusterXxx() (#47203)
ReentrantLock may consume lots of CPU in some cases. Remove some redundant rlock to prevent the potential CPU issue.
1 parent 089ef91 commit 663fb7c
Copy full SHA for 663fb7c

File tree

1 file changed

+16
-40
lines changed
Filter options

1 file changed

+16
-40
lines changed

‎fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java

Copy file name to clipboardExpand all lines: fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java
+16-40Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,7 @@ public boolean availableBackendsExists() {
492492
}
493493

494494
public boolean containClusterName(String clusterName) {
495-
rlock.lock();
496-
try {
497-
return clusterNameToId.containsKey(clusterName);
498-
} finally {
499-
rlock.unlock();
500-
}
495+
return clusterNameToId.containsKey(clusterName);
501496
}
502497

503498
@Override
@@ -550,27 +545,17 @@ public ImmutableMap<Long, Backend> getBackendsByCurrentCluster() throws Analysis
550545
}
551546

552547
public List<Backend> getBackendsByClusterName(final String clusterName) {
553-
rlock.lock();
554-
try {
555-
String clusterId = clusterNameToId.getOrDefault(clusterName, "");
556-
if (clusterId.isEmpty()) {
557-
return new ArrayList<>();
558-
}
559-
// copy a new List
560-
return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>()));
561-
} finally {
562-
rlock.unlock();
548+
String clusterId = clusterNameToId.getOrDefault(clusterName, "");
549+
if (clusterId.isEmpty()) {
550+
return new ArrayList<>();
563551
}
552+
// copy a new List
553+
return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>()));
564554
}
565555

566556
public List<Backend> getBackendsByClusterId(final String clusterId) {
567-
rlock.lock();
568-
try {
569-
// copy a new List
570-
return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>()));
571-
} finally {
572-
rlock.unlock();
573-
}
557+
// copy a new List
558+
return new ArrayList<>(clusterIdToBackend.getOrDefault(clusterId, new ArrayList<>()));
574559
}
575560

576561
public String getClusterNameByBeAddr(String beEndpoint) {
@@ -588,27 +573,18 @@ public String getClusterNameByBeAddr(String beEndpoint) {
588573
}
589574

590575
public List<String> getCloudClusterIds() {
591-
rlock.lock();
592-
try {
593-
return new ArrayList<>(clusterIdToBackend.keySet());
594-
} finally {
595-
rlock.unlock();
596-
}
576+
return new ArrayList<>(clusterIdToBackend.keySet());
597577
}
598578

599579
public String getCloudStatusByName(final String clusterName) {
600-
rlock.lock();
601-
try {
602-
String clusterId = clusterNameToId.getOrDefault(clusterName, "");
603-
if (Strings.isNullOrEmpty(clusterId)) {
604-
// for rename cluster or dropped cluster
605-
LOG.warn("cant find clusterId by clusteName {}", clusterName);
606-
return "";
607-
}
608-
return getCloudStatusByIdNoLock(clusterId);
609-
} finally {
610-
rlock.unlock();
580+
String clusterId = clusterNameToId.getOrDefault(clusterName, "");
581+
if (Strings.isNullOrEmpty(clusterId)) {
582+
// for rename cluster or dropped cluster
583+
LOG.warn("cant find clusterId by clusteName {}", clusterName);
584+
return "";
611585
}
586+
// It is safe to return a null/empty status string, the caller handles it properly
587+
return getCloudStatusByIdNoLock(clusterId);
612588
}
613589

614590
public String getCloudStatusById(final String clusterId) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.