zhangshuyan0 commented on code in PR #6717:
URL: https://github.com/apache/hadoop/pull/6717#discussion_r1565660296


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaMap.java:
##########
@@ -120,15 +118,13 @@ ReplicaInfo get(String bpid, long blockId) {
   ReplicaInfo add(String bpid, ReplicaInfo replicaInfo) {
     checkBlockPool(bpid);
     checkBlock(replicaInfo);
-    try (AutoCloseDataSetLock l = lockManager.readLock(LockLevel.BLOCK_POOl, 
bpid)) {
-      LightWeightResizableGSet<Block, ReplicaInfo> m = map.get(bpid);
-      if (m == null) {
-        // Add an entry for block pool if it does not exist already
-        map.putIfAbsent(bpid, new LightWeightResizableGSet<Block, 
ReplicaInfo>());
-        m = map.get(bpid);
-      }
-      return  m.put(replicaInfo);
+    LightWeightResizableGSet<Block, ReplicaInfo> m = map.get(bpid);
+    if (m == null) {
+      // Add an entry for block pool if it does not exist already
+      map.putIfAbsent(bpid, new LightWeightResizableGSet<Block, 
ReplicaInfo>());
+      m = map.get(bpid);
     }
+    return m.put(replicaInfo);

Review Comment:
   It's not safe here. If there is somebody  changing the `map` after line125 
but before line127, the `replicaInfo` may not be able to added to `map`.



-- 
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