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

zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new 4eb83eea2 [#2571] fix(client): Race condition when adding shuffle 
servers (#2574)
4eb83eea2 is described below

commit 4eb83eea26a02a83372f88378399ceb0075858c8
Author: Junfan Zhang <[email protected]>
AuthorDate: Tue Aug 5 17:40:07 2025 +0800

    [#2571] fix(client): Race condition when adding shuffle servers (#2574)
    
    ### What changes were proposed in this pull request?
    
    Using the thread safe way to add shuffle-servers to emlinate race condition
    
    ### Why are the changes needed?
    
    fix #2571
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Needn't
---
 .../apache/uniffle/client/impl/ShuffleWriteClientImpl.java | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git 
a/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java
 
b/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java
index b846dbb82..3855debfa 100644
--- 
a/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java
+++ 
b/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java
@@ -1228,16 +1228,10 @@ public class ShuffleWriteClientImpl implements 
ShuffleWriteClient {
   }
 
   void addShuffleServer(String appId, int shuffleId, ShuffleServerInfo 
serverInfo) {
-    Map<Integer, Set<ShuffleServerInfo>> appServerMap = 
shuffleServerInfoMap.get(appId);
-    if (appServerMap == null) {
-      appServerMap = JavaUtils.newConcurrentMap();
-      shuffleServerInfoMap.put(appId, appServerMap);
-    }
-    Set<ShuffleServerInfo> shuffleServerInfos = appServerMap.get(shuffleId);
-    if (shuffleServerInfos == null) {
-      shuffleServerInfos = Sets.newConcurrentHashSet();
-      appServerMap.put(shuffleId, shuffleServerInfos);
-    }
+    Map<Integer, Set<ShuffleServerInfo>> appServerMap =
+        shuffleServerInfoMap.computeIfAbsent(appId, x -> 
JavaUtils.newConcurrentMap());
+    Set<ShuffleServerInfo> shuffleServerInfos =
+        appServerMap.computeIfAbsent(shuffleId, x -> 
Sets.newConcurrentHashSet());
     shuffleServerInfos.add(serverInfo);
   }
 

Reply via email to