-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: Handle lastFetchedEpoch/divergingEpoch in FetchSession and DelayedFetch #9434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,8 @@ class CachedPartition(val topic: String, | |
| var highWatermark: Long, | ||
| var leaderEpoch: Optional[Integer], | ||
| var fetcherLogStartOffset: Long, | ||
| var localLogStartOffset: Long) | ||
| var localLogStartOffset: Long, | ||
| var lastFetchedEpoch: Optional[Integer] = Optional.empty[Integer]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to provide a default here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
| extends ImplicitLinkedHashCollection.Element { | ||
|
|
||
| var cachedNext: Int = ImplicitLinkedHashCollection.INVALID_INDEX | ||
|
|
@@ -96,21 +97,22 @@ class CachedPartition(val topic: String, | |
|
|
||
| def this(part: TopicPartition, reqData: FetchRequest.PartitionData) = | ||
| this(part.topic, part.partition, reqData.maxBytes, reqData.fetchOffset, -1, | ||
| reqData.currentLeaderEpoch, reqData.logStartOffset, -1) | ||
| reqData.currentLeaderEpoch, reqData.logStartOffset, -1, reqData.lastFetchedEpoch) | ||
|
|
||
| def this(part: TopicPartition, reqData: FetchRequest.PartitionData, | ||
| respData: FetchResponse.PartitionData[Records]) = | ||
| this(part.topic, part.partition, reqData.maxBytes, reqData.fetchOffset, respData.highWatermark, | ||
| reqData.currentLeaderEpoch, reqData.logStartOffset, respData.logStartOffset) | ||
| reqData.currentLeaderEpoch, reqData.logStartOffset, respData.logStartOffset, reqData.lastFetchedEpoch) | ||
|
|
||
| def reqData = new FetchRequest.PartitionData(fetchOffset, fetcherLogStartOffset, maxBytes, leaderEpoch) | ||
| def reqData = new FetchRequest.PartitionData(fetchOffset, fetcherLogStartOffset, maxBytes, leaderEpoch, lastFetchedEpoch) | ||
|
|
||
| def updateRequestParams(reqData: FetchRequest.PartitionData): Unit = { | ||
| // Update our cached request parameters. | ||
| maxBytes = reqData.maxBytes | ||
| fetchOffset = reqData.fetchOffset | ||
| fetcherLogStartOffset = reqData.logStartOffset | ||
| leaderEpoch = reqData.currentLeaderEpoch | ||
| lastFetchedEpoch = reqData.lastFetchedEpoch | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1084,7 +1084,7 @@ class ReplicaManager(val config: KafkaConfig, | |
| fetchInfos.foreach { case (topicPartition, partitionData) => | ||
| logReadResultMap.get(topicPartition).foreach(logReadResult => { | ||
| val logOffsetMetadata = logReadResult.info.fetchOffsetMetadata | ||
| fetchPartitionStatus += (topicPartition -> FetchPartitionStatus(logOffsetMetadata, partitionData)) | ||
| fetchPartitionStatus += (topicPartition -> FetchPartitionStatus(logOffsetMetadata, partitionData, logReadResult.divergingEpoch.nonEmpty)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.. If the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, yes, so we don't need to check the original result in DelayedFetch, we return immediately here. Updated. |
||
| }) | ||
| } | ||
| val fetchMetadata: SFetchMetadata = SFetchMetadata(fetchMinBytes, fetchMaxBytes, hardMaxBytesLimit, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are using the status from the original fetch. I am wondering if we need to recheck below since it is possible to get a truncation while a fetch is in purgatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hachikuji Thanks for the review. Makes sense, I have added a new check at the end instead of this one, not sure if there is a better way to check.