kevin-wu24 opened a new pull request, #23940: URL: https://github.com/apache/kafka/pull/23940
Cherry-pick of #23737 to the `4.2` branch. When the metadata layer (e.g. `MetadataLoader`) reads a slice of records from KRaft that is larger than `KafkaRaftClient#MAX_BATCH_SIZE_BYTES`, `RecordsIterator` can return records past the end of the slice (the HWM). `FileRecords#readInto` reads up to the end of the underlying file instead of the end of the `FileRecords` slice, which can lead to a metadata error where the node tries to snapshot with records past the HWM. This change bounds `FileRecords#readInto` to the end of the `FileRecords` object, so reading a `[start position, HWM)` slice never reads bytes past the HWM into memory. `RecordsIterator` also stops growing its buffer once it has read the whole slice, since a trailing partial batch can't be completed. Original PR: https://github.com/apache/kafka/pull/23737 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
