hachikuji commented on a change in pull request #9816: URL: https://github.com/apache/kafka/pull/9816#discussion_r557818816
########## File path: core/src/main/scala/kafka/raft/KafkaMetadataLog.scala ########## @@ -147,18 +221,102 @@ class KafkaMetadataLog( } override def createSnapshot(snapshotId: raft.OffsetAndEpoch): RawSnapshotWriter = { - FileRawSnapshotWriter.create(log.dir.toPath, snapshotId) + // Do not let the state machine create snapshots older than the latest snapshot + latestSnapshotId().ifPresent { latest => + if (latest.epoch > snapshotId.epoch || latest.offset > snapshotId.offset) { + // Since snapshots are less than the high-watermark absolute offset comparison is okay. Review comment: Is it useful here to ensure that `snapshotId` is indeed lower than the high watermark? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org