You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/10/08 07:26:59 UTC

[GitHub] [ozone] Xushaohong commented on a diff in pull request #3778: HDDS-7258. Cleanup the allocated but uncommitted blocks

Xushaohong commented on code in PR #3778:
URL: https://github.com/apache/ozone/pull/3778#discussion_r990604640


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java:
##########
@@ -214,17 +219,29 @@ public void updateLocationInfoList(List<OmKeyLocationInfo> locationInfoList,
       updatedBlockLocations =
           verifyAndGetKeyLocations(locationInfoList, keyLocationInfoGroup);
     }
-    // Updates the latest locationList in the latest version only with
-    // given locationInfoList here.
-    // TODO : The original allocated list and the updated list here may vary
-    // as the containers on the Datanode on which the blocks were pre allocated
-    // might get closed. The diff of blocks between these two lists here
-    // need to be garbage collected in case the ozone client dies.
+
+    // Every time the key commits, the uncommitted blocks should be detected
+    // If client not commit, the blocks should be cleaned by Open Key CleanUp
+    // Service.
+    // keyLocationInfoGroup has the allocated block location info
+    List<OmKeyLocationInfo> uncommittedBlocks =
+        new ArrayList<>(keyLocationInfoGroup.getBlocksLatestVersionOnly());
+    // Only check ContainerBlockID here to avoid the mismatch of the pipeline
+    // field and BcsId in the OmKeyLocationInfo, as the OmKeyInfoCodec ignores
+    // the pipeline field by default and bcsId would be updated in Ratis mode.
+    List<ContainerBlockID> updatedBlockIDs = updatedBlockLocations.stream().
+        map(BlockLocationInfo::getBlockID).map(BlockID::getContainerBlockID).
+        collect(Collectors.toList());
+    uncommittedBlocks.removeIf(block -> updatedBlockIDs.

Review Comment:
   List<ContainerBlockID> updatedBlockIDs 
   List<OmKeyLocationInfo> uncommittedBlocks 
   
   They have two kinds of element types.



-- 
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: issues-unsubscribe@ozone.apache.org

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


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