lucasbru commented on code in PR #24193:
URL: https://github.com/apache/kafka/pull/24193#discussion_r4640843250


##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -462,13 +465,19 @@ Map<TopicPartition, OffsetsInfo> 
getOffsets(StreamsGroupDescription description)
             for (StreamsGroupMemberDescription memberDescription : members) {
                 
allTp.addAll(getTopicPartitions(memberDescription.assignment().activeTasks(), 
description));
             }
+            // A member that stopped without leaving the group keeps its 
assignment until its session times out, so the
+            // assignment can reference a topic or partition that has since 
been deleted. listOffsets would fail or retry
+            // until the timeout for those, so only query partitions with a 
leader and report the rest as unknown.
+            List<TopicPartition> partitionsWithoutLeader = 
groupOffsetsResetter.filterNoneLeaderPartitions(allTp);
             // fetch latest and earliest offsets
             Map<TopicPartition, OffsetSpec> earliest = new HashMap<>();
             Map<TopicPartition, OffsetSpec> latest = new HashMap<>();
 
             for (TopicPartition tp : allTp) {
-                earliest.put(tp, OffsetSpec.earliest());
-                latest.put(tp, OffsetSpec.latest());
+                if (!partitionsWithoutLeader.contains(tp)) {

Review Comment:
   Should be a small list, but a loop with a linear-time lookup is always a 
smell.



##########
tools/src/main/java/org/apache/kafka/tools/GroupOffsetsResetter.java:
##########
@@ -456,20 +457,32 @@ public void 
checkAllTopicPartitionsValid(Collection<TopicPartition> partitionsTo
     }
 
     public List<TopicPartition> 
filterNoneLeaderPartitions(Collection<TopicPartition> topicPartitions) {

Review Comment:
   This is the same change as #24098, so the two PRs will conflict here, and 
this PR changes `kafka-consumer-groups.sh --describe` as a side effect without 
its tests. Could we drop the `GroupOffsetsResetter` change from this PR and 
build on #24098 once it's merged?
   
   I also have doubts about the change itself. Why are we calling a function in 
`GroupOffsetsResetter` from the describe code? That seems like an unsound 
separation of concerns, even if the consumer groups CLI already does it. If we 
really want to share this helper, it should live somewhere else. And given what 
we want here, `filterNonExistentPartitions` right below seems like a better fit 
than changing `filterNoneLeaderPartitions`. But that's probably a discussion 
for #24098.
   
   cc @squah-confluent (not sure who is actually looking into consumer group 
CLI things normally).
   



-- 
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]

Reply via email to