pramithas commented on code in PR #18482: URL: https://github.com/apache/kafka/pull/18482#discussion_r1922357825
########## 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: @junrao As you mentioned, the mmap is constructed and cached at the time of index creation. And, sanity check reads the cached value itself since it is invoked immediately after index construction. So, it seems like sanityCheck() will read the value from cache always. @divijvaidya Do you know particular cases where this does not hold true? -- 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