Jason Gustafson created KAFKA-9886: -------------------------------------- Summary: Validate segment range before reading in `Log.read` Key: KAFKA-9886 URL: https://issues.apache.org/jira/browse/KAFKA-9886 Project: Kafka Issue Type: Improvement Reporter: Jason Gustafson Assignee: Jason Gustafson
Log.read uses the following logic to set the upper limit on a segment read. {code} val maxPosition = { // Use the max offset position if it is on this segment; otherwise, the segment size is the limit. if (maxOffsetMetadata.segmentBaseOffset == segment.baseOffset) { maxOffsetMetadata.relativePositionInSegment } else { segment.size } } {code} In the else branch, the expectation is that `maxOffsetMetadata.segmentBaseOffset > segment.baseOffset`. In KAFKA-9838, we found a bug where this assumption failed which led to reads above the high watermark. We should validate the expectation explicitly so that we don't leave the door open for similar bugs in the future. -- This message was sent by Atlassian Jira (v8.3.4#803005)