hachikuji commented on code in PR #12653:
URL: https://github.com/apache/kafka/pull/12653#discussion_r973361028
##########
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:
I guess a specific case where doing this prior to `recoverSnapshots` might
help is if we have a deleted file corresponding to a snapshot in the range we
are looking for.
--
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]