hachikuji commented on code in PR #12653:
URL: https://github.com/apache/kafka/pull/12653#discussion_r973350559
##########
core/src/main/scala/kafka/raft/KafkaMetadataLog.scala:
##########
@@ -48,6 +48,17 @@ final class KafkaMetadataLog private (
this.logIdent = s"[MetadataLog partition=$topicPartition,
nodeId=${config.nodeId}] "
+ // If the log start offset is not 0, then we must have a snapshot which
covers the
+ // initial state up to the current log start offset.
+ if (log.logStartOffset > 0) {
+ val latestSnapshotId = snapshots.lastOption.map(_._1)
+ if (!latestSnapshotId.exists(snapshotId => snapshotId.offset >=
log.logStartOffset)) {
+ throw new IllegalStateException("Inconsistent snapshot state: there must
be a snapshot " +
+ s"at an offset larger then the current log start offset
${log.logStartOffset}, but the " +
+ s"latest snapshot is ${latestSnapshotId}")
+ }
+ }
+
Review Comment:
Makes sense.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]