-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-7044: Fix Fetcher.fetchOffsetsByTimes and NPE in describe consumer group #5627
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
474bfb4
KAFKA-7044: Fix early return from fetchOffsetsByTimes and fix NPE in …
apovzner 3306849
New test exceeded default max number of lines in the FetcherTest class
apovzner 4f1a6a0
addressed review comments
apovzner aec7385
cleanup
apovzner e71e6f4
passing partitions to retry to groupListOffsetRequests
apovzner 1f8fbd8
removed printing partitions to retry in resetOffsetsAsync
apovzner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -292,12 +292,8 @@ object ConsumerGroupCommand extends Logging { | |
| } | ||
|
|
||
| getLogEndOffsets(topicPartitions).map { | ||
| logEndOffsetResult => | ||
| logEndOffsetResult._2 match { | ||
| case LogOffsetResult.LogOffset(logEndOffset) => getDescribePartitionResult(logEndOffsetResult._1, Some(logEndOffset)) | ||
| case LogOffsetResult.Unknown => getDescribePartitionResult(logEndOffsetResult._1, None) | ||
| case LogOffsetResult.Ignore => null | ||
|
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. As far as I can tell, this was the only use of If we did that, then we could probably also get rid of |
||
| } | ||
| case (topicPartition, LogOffsetResult.LogOffset(offset)) => getDescribePartitionResult(topicPartition, Some(offset)) | ||
| case (topicPartition, _) => getDescribePartitionResult(topicPartition, None) | ||
| }.toArray | ||
| } | ||
|
|
||
|
|
@@ -399,16 +395,20 @@ object ConsumerGroupCommand extends Logging { | |
| private def getLogEndOffsets(topicPartitions: Seq[TopicPartition]): Map[TopicPartition, LogOffsetResult] = { | ||
| val offsets = getConsumer.endOffsets(topicPartitions.asJava) | ||
| topicPartitions.map { topicPartition => | ||
| val logEndOffset = offsets.get(topicPartition) | ||
| topicPartition -> LogOffsetResult.LogOffset(logEndOffset) | ||
| Option(offsets.get(topicPartition)) match { | ||
| case Some(logEndOffset) => topicPartition -> LogOffsetResult.LogOffset(logEndOffset) | ||
| case _ => topicPartition -> LogOffsetResult.Unknown | ||
| } | ||
| }.toMap | ||
| } | ||
|
|
||
| private def getLogStartOffsets(topicPartitions: Seq[TopicPartition]): Map[TopicPartition, LogOffsetResult] = { | ||
| val offsets = getConsumer.beginningOffsets(topicPartitions.asJava) | ||
| topicPartitions.map { topicPartition => | ||
| val logStartOffset = offsets.get(topicPartition) | ||
| topicPartition -> LogOffsetResult.LogOffset(logStartOffset) | ||
| Option(offsets.get(topicPartition)) match { | ||
| case Some(logStartOffset) => topicPartition -> LogOffsetResult.LogOffset(logStartOffset) | ||
| case _ => topicPartition -> LogOffsetResult.Unknown | ||
| } | ||
| }.toMap | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I moved the logic for getting the list of partitions that do not have available leader to
groupListOffsetRequests. I was contemplating whether we should add partition for which we have a failed connection to leader topartitionsToRetry. Seems like we should, because we may be able to reconnect before the list offsets timeout.