GlenGeng commented on a change in pull request #2291:
URL: https://github.com/apache/ozone/pull/2291#discussion_r641474736



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ReplicationManager.java
##########
@@ -878,6 +871,24 @@ private void handleOverReplicatedContainer(final 
ContainerInfo container,
         Set<ContainerReplica> eligibleSet = new HashSet<>(eligibleReplicas);
         ContainerPlacementStatus ps =
             getPlacementStatus(eligibleSet, replicationFactor);
+
+        // Iterate replicas in deterministic order to avoid potential data 
loss.
+        // See https://issues.apache.org/jira/browse/HDDS-4589.
+        // N.B., sort replicas by (containerID, datanodeDetails).
+        // what is more , for all the deletion candidate replicas,
+        // we always delete the one with highest storage.
+        // See https://issues.apache.org/jira/browse/HDDS-5278
+        eligibleReplicas.sort((r1, r2) -> {
+          int result = nodeManager.getNodeStatInternal(r1.getDatanodeDetails())
+              .compareByRemainingRatio(nodeManager.

Review comment:
       Can sorting based on usage be deterministic, and theoretically avoid the 
potential data loss issue?




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



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

Reply via email to