kevin-wu24 commented on code in PR #17500: URL: https://github.com/apache/kafka/pull/17500#discussion_r1806720088
########## raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java: ########## @@ -3426,6 +3428,12 @@ public Optional<SnapshotWriter<T>> createSnapshot( throw new IllegalStateException("Cannot create snapshot before the replica has been initialized"); } + AbstractIterator<? extends RecordBatch> batchIterator = log.read(snapshotId.offset(), Isolation.COMMITTED).records.batchIterator(); + if (batchIterator.hasNext() && batchIterator.peek().baseOffset() != snapshotId.offset()) { + logger.error("Cannot create snapshot at offset {} because it is not batch aligned", snapshotId.offset()); + return Optional.empty(); + } Review Comment: Agreed. Just checking the offset when it actually returns the batch start offset is more readable. -- 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