chia7712 opened a new pull request, #15621: URL: https://github.com/apache/kafka/pull/15621
We do iterate the records to find the `offsetOfMaxTimestamp` instead of returning the cached one when handling `ListOffsetsRequest.MAX_TIMESTAMP`, since it is hard to align all paths to get correct `offsetOfMaxTimestamp`. The known paths are shown below. 1. `convertAndAssignOffsetsNonCompressed` -> we CAN get correct `offsetOfMaxTimestamp` when validating all records 2. `assignOffsetsNonCompressed` -> ditto 3. `validateMessagesAndAssignOffsetsCompressed` -> ditto 4. `validateMessagesAndAssignOffsetsCompressed#buildRecordsAndAssignOffsets` -> ditto 5. `appendAsFollow#append#analyzeAndValidateRecords` -> we CAN'T get correct `offsetOfMaxTimestamp` as iterating all records is expensive when fetching records from leader 6. `LogSegment#recover` -> ditto https://issues.apache.org/jira/browse/KAFKA-16310 ### Committer Checklist (excluded from commit message) - [ ] Verify design and implementation - [ ] Verify test coverage and CI build status - [ ] Verify documentation (including upgrade notes) -- 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