You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2023/04/20 18:16:26 UTC

[GitHub] [ozone] adoroszlai commented on a diff in pull request #4599: HDDS-8416. ReplicationManager: RatisUnderReplication handler should filter sources by highest BCSID

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