showuon commented on code in PR #15817: URL: https://github.com/apache/kafka/pull/15817#discussion_r1589925627
########## core/src/main/java/kafka/log/remote/RemoteLogManager.java: ########## @@ -1245,19 +1260,27 @@ public static boolean isRemoteSegmentWithinLeaderEpochs(RemoteLogSegmentMetadata return false; } - // Segment's first epoch's offset should be more than or equal to the respective leader epoch's offset. - if (epoch == segmentFirstEpoch && offset < leaderEpochs.get(epoch)) { - LOGGER.debug("Segment {} first epoch {} offset is less than leader epoch offset {}.", - segmentMetadata.remoteLogSegmentId(), epoch, leaderEpochs.get(epoch)); + // Two cases: + // case-1: When the segment-first-epoch equals to the first-epoch in the leader-epoch-lineage, then the + // offset value can lie anywhere between 0 to (next-epoch-start-offset - 1) is valid. + // case-2: When the segment-first-epoch is not equal to the first-epoch in the leader-epoch-lineage, then + // the offset value should be between (current-epoch-start-offset) to (next-epoch-start-offset - 1). + if (epoch == segmentFirstEpoch && leaderEpochs.lowerKey(epoch) != null && offset < leaderEpochs.get(epoch)) { + LOGGER.debug("Segment {} first-valid epoch {} offset is less than leader epoch offset {}." + Review Comment: nit: is less than "first" leader epoch offset... -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org