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


##########
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:
   `Long getSequenceId()` may return `null`, so for safety we may add a filter 
in the stream collecting `availableSources` above.
   
   ```
           .filter(r -> r.getSequenceId() != null)
   ```
   
   Not strictly necessary, as I'm not sure all other code handles `null` 
gracefully.



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