You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/09/18 12:38:19 UTC

[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4903: HDFS-16774.Improve async delete replica on datanode

slfan1989 commented on code in PR #4903:
URL: https://github.com/apache/hadoop/pull/4903#discussion_r973714519


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetAsyncDiskService.java:
##########
@@ -359,6 +371,89 @@ public void run() {
         IOUtils.cleanupWithLogger(null, this.volumeRef);
       }
     }
+
+    private boolean removeReplicaFromMem() {
+      try (AutoCloseableLock lock = fsdatasetImpl.acquireDatasetLockManager().writeLock(
+          DataNodeLockManager.LockLevel.BLOCK_POOl, block.getBlockPoolId())) {
+        final ReplicaInfo info = fsdatasetImpl.volumeMap
+            .get(block.getBlockPoolId(), block.getLocalBlock());
+        if (info == null) {
+          ReplicaInfo infoByBlockId =
+              fsdatasetImpl.volumeMap.get(block.getBlockPoolId(),
+                  block.getLocalBlock().getBlockId());
+          if (infoByBlockId == null) {
+            // It is okay if the block is not found -- it
+            // may be deleted earlier.
+            LOG.info("Failed to delete replica " + block.getLocalBlock()
+                + ": ReplicaInfo not found in removeReplicaFromMem.");
+          } else {
+            LOG.error("Failed to delete replica " + block.getLocalBlock()
+                + ": GenerationStamp not matched, existing replica is "
+                + Block.toString(infoByBlockId) + " in removeReplicaFromMem.");
+          }
+          return false;
+        }
+
+        FsVolumeImpl v = (FsVolumeImpl)info.getVolume();
+        if (v == null) {
+          LOG.error("Failed to delete replica " + block.getLocalBlock()
+              +  ". No volume for this replica " + info + " in removeReplicaFromMem.");

Review Comment:
   Should we use {}



-- 
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-unsubscribe@hadoop.apache.org

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


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