lokeshj1703 commented on a change in pull request #1318: HDDS-1753. Datanode 
unable to find chunk while replication data using ratis.
URL: https://github.com/apache/hadoop/pull/1318#discussion_r316217524
 
 

 ##########
 File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java
 ##########
 @@ -236,14 +244,43 @@ public ContainerReportsProto getContainerReport() throws 
IOException {
       ContainerDeletionChoosingPolicy deletionPolicy)
       throws StorageContainerException {
     Map<Long, ContainerData> containerDataMap = 
containerMap.entrySet().stream()
-        .filter(e -> deletionPolicy.isValidContainerType(
-            e.getValue().getContainerType()))
-        .collect(Collectors.toMap(Map.Entry::getKey,
-            e -> e.getValue().getContainerData()));
+        .filter(e ->
+            
deletionPolicy.isValidContainerType(e.getValue().getContainerType())
+                && isDeletionAllowed(e.getValue().getContainerData())).collect(
+            Collectors.toMap(Map.Entry::getKey,
+                e -> e.getValue().getContainerData()));
     return deletionPolicy
         .chooseContainerForBlockDeletion(count, containerDataMap);
   }
 
+  private boolean isDeletionAllowed(ContainerData containerData) {
+    if (containerData.isClosed()) {
+      if (writeChannel instanceof XceiverServerRatis) {
+        try {
+          XceiverServerRatis ratisServer = (XceiverServerRatis) writeChannel;
+          long minReplicatedIndex = 
ratisServer.getMinReplicatedIndex(PipelineID
+              .valueOf(UUID.fromString(containerData.getOriginPipelineId())));
+          long containerBCSID = containerData.getBlockCommitSequenceId();
+          if (minReplicatedIndex != 0 && minReplicatedIndex < containerBCSID) {
 
 Review comment:
   There can be a corner case where minReplicatedIndex is 0 and pipeline is 
still active?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to