adoroszlai commented on code in PR #4599:
URL: https://github.com/apache/ozone/pull/4599#discussion_r1172946485


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisUnderReplicationHandler.java:
##########
@@ -217,7 +217,15 @@ private List<DatanodeDetails> getSources(
           }
         })
         .filter(r -> !pendingDeletion.contains(r.getDatanodeDetails()))
-        .sorted((r1, r2) -> r2.getSequenceId().compareTo(r1.getSequenceId()))
+        .collect(Collectors.toList());
+
+    // We should replicate only the max available sequence ID, as replicas with
+    // earlier sequence IDs may be stale copies.
+    long maxSequenceId = availableSources.stream()
+        .map(ContainerReplica::getSequenceId).max(Long::compareTo).orElse(0L);

Review Comment:
   > might even be better to change the map step to return zero if 
getSequenceId returns null. That way, if for some strange reason all replicas 
don't have a sequenceID we just use any of them, rather than filter all of them 
out.
   
   Good point.



-- 
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: [email protected]

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