junrao commented on code in PR #18482: URL: https://github.com/apache/kafka/pull/18482#discussion_r1915465354
########## storage/src/main/java/org/apache/kafka/storage/internals/log/TimeIndex.java: ########## @@ -76,16 +76,16 @@ public void sanityCheck() { TimestampOffset entry = lastEntry(); long lastTimestamp = entry.timestamp; long lastOffset = entry.offset; - if (entries() != 0 && lastTimestamp < timestamp(mmap(), 0)) - throw new CorruptIndexException("Corrupt time index found, time index file (" + file().getAbsolutePath() + ") has " - + "non-zero size but the last timestamp is " + lastTimestamp + " which is less than the first timestamp " - + timestamp(mmap(), 0)); if (entries() != 0 && lastOffset < baseOffset()) throw new CorruptIndexException("Corrupt time index found, time index file (" + file().getAbsolutePath() + ") has " + "non-zero size but the last offset is " + lastOffset + " which is less than the first offset " + baseOffset()); if (length() % ENTRY_SIZE != 0) throw new CorruptIndexException("Time index file " + file().getAbsolutePath() + " is corrupt, found " + length() + " bytes which is neither positive nor a multiple of " + ENTRY_SIZE); + if (entries() != 0 && lastTimestamp < timestamp(mmap(), 0)) Review Comment: The change doesn't hurt, but I am not sure if it actually makes things better. All calls to `sanityCheck` happen immediately after the construction of TimeIndex. During the construction, we call `lastEntryFromIndexFile`, which calls mmap(). -- 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