jsancio commented on code in PR #17500: URL: https://github.com/apache/kafka/pull/17500#discussion_r1806631640
########## 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: I know that I agreed to this solution in our offline discussion but since we are planning to change the UnifiedLog implementation to return the batch start offset in the LogOffsetMetadata, then maybe it is better to fix that PR (https://github.com/apache/kafka/pull/17528) first and merge it. After that we can fix this PR and Jira using the changes in the other PR. -- 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