github-actions[bot] commented on code in PR #63636:
URL: https://github.com/apache/doris/pull/63636#discussion_r3322608493


##########
fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java:
##########
@@ -118,16 +119,90 @@ public void renameVirtualClusterInfoFromMapsNoLock(String 
clusterId, String oldC
     }
 
     public ComputeGroup getComputeGroupByName(String computeGroupName) {
-        LOG.debug("get id {} computeGroupIdToComputeGroup : {} ", 
computeGroupName, computeGroupIdToComputeGroup);
-        try {
-            rlock.lock();
-            if (!clusterNameToId.containsKey(computeGroupName)) {
-                return null;
+        // Both maps are ConcurrentHashMap, so no extra lock is needed on the 
read path.
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("get id {} computeGroupIdToComputeGroup : {} ", 
computeGroupName, computeGroupIdToComputeGroup);
+        }
+        String id = clusterNameToId.get(computeGroupName);
+        return id == null ? null : computeGroupIdToComputeGroup.get(id);

Review Comment:
   This lock-free lookup breaks the compound invariant that the write side is 
still protecting with `wlock`. `clusterNameToId` and 
`computeGroupIdToComputeGroup` are updated together in `addComputeGroup`, 
`removeComputeGroup`, and `renameVirtualComputeGroup`; making this reader use 
two independent `ConcurrentHashMap` reads means it can observe a 
partially-applied update. For example, during a virtual compute group 
rename/removal, `getPhysicalCluster()` can get `null` here and treat the 
virtual group name as a physical cluster, so `getCurrentClusterId()` 
resolves/checks the wrong cluster or returns `CURRENT_COMPUTE_GROUP_NOT_EXIST` 
for an otherwise valid request. `ConcurrentHashMap` only makes each individual 
map operation safe; it does not preserve the cross-map consistency the previous 
`rlock` provided. Please keep the read lock here, or replace these maps with a 
single atomically published lookup structure for the hot path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to