You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/09/16 20:06:18 UTC
[GitHub] [kafka] jsancio commented on a diff in pull request #12653: KAFKA-14240; Validate kraft snapshot state on startup
jsancio commented on code in PR #12653:
URL: https://github.com/apache/kafka/pull/12653#discussion_r973349293
##########
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:
What do you think about moving this check to `recoverSnapshots` or before calling `recoverSnapshots`?
`recoverSnapshots` makes changes to the log dir. Kafka should probably validate the log dir before making changes to it?
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org