MingXiangLi commented on code in PR #4558:
URL: https://github.com/apache/hadoop/pull/4558#discussion_r922773966


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java:
##########
@@ -2312,23 +2312,23 @@ private void invalidate(String bpid, Block[] 
invalidBlks, boolean async)
     for (int i = 0; i < invalidBlks.length; i++) {
       final ReplicaInfo removing;
       final FsVolumeImpl v;
-      try (AutoCloseableLock lock = 
lockManager.writeLock(LockLevel.BLOCK_POOl, bpid)) {
-        final ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]);
-        if (info == null) {
-          ReplicaInfo infoByBlockId =
-              volumeMap.get(bpid, invalidBlks[i].getBlockId());
-          if (infoByBlockId == null) {
-            // It is okay if the block is not found -- it
-            // may be deleted earlier.
-            LOG.info("Failed to delete replica " + invalidBlks[i]
-                + ": ReplicaInfo not found.");
-          } else {
-            errors.add("Failed to delete replica " + invalidBlks[i]
-                + ": GenerationStamp not matched, existing replica is "
-                + Block.toString(infoByBlockId));
-          }
-          continue;
+      final ReplicaInfo info = volumeMap.get(bpid, invalidBlks[i]);
+      if (info == null) {
+        ReplicaInfo infoByBlockId =
+                volumeMap.get(bpid, invalidBlks[i].getBlockId());
+        if (infoByBlockId == null) {
+          // It is okay if the block is not found -- it
+          // may be deleted earlier.
+          LOG.info("Failed to delete replica " + invalidBlks[i]
+                  + ": ReplicaInfo not found.");
+        } else {
+          errors.add("Failed to delete replica " + invalidBlks[i]
+                  + ": GenerationStamp not matched, existing replica is "
+                  + Block.toString(infoByBlockId));
         }
+        continue;
+      }
+      try (AutoCloseableLock lock = lockManager.writeLock(LockLevel.VOLUME, 
bpid, info.getStorageUuid())) {

Review Comment:
   This is the reason I acquire block pool lock before...Or we sort these block 
and batch processing with the same volume? 



-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to