You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "HaiyuanZhao (Jira)" <ji...@apache.org> on 2021/09/05 10:24:00 UTC

[jira] [Assigned] (KAFKA-9886) Validate segment range before reading in `Log.read`

     [ https://issues.apache.org/jira/browse/KAFKA-9886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

HaiyuanZhao reassigned KAFKA-9886:
----------------------------------

    Assignee: HaiyuanZhao

> 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: HaiyuanZhao
>            Priority: Major
>
> 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)