lucasbru commented on code in PR #24321:
URL: https://github.com/apache/kafka/pull/24321#discussion_r4643431165
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -462,6 +462,14 @@ Map<TopicPartition, OffsetsInfo>
getOffsets(StreamsGroupDescription description)
for (StreamsGroupMemberDescription memberDescription : members) {
allTp.addAll(getTopicPartitions(memberDescription.assignment().activeTasks(),
description));
}
+ // Also include partitions that have committed offsets but are not
assigned to any member,
+ // e.g., when the group is empty, so that their committed offsets
are still shown.
+ Map<TopicPartition, OffsetAndMetadata> committedOffsets =
getCommittedOffsets(description.groupId());
+ committedOffsets.forEach((tp, offsetAndMetadata) -> {
+ if (offsetAndMetadata != null) {
+ allTp.add(tp);
Review Comment:
With this, describing an empty group can now fail entirely if one of its
committed partitions has no leader: listOffsets retries until the API timeout
and `all().get()` throws, so none of the other partitions get shown. Before,
only assigned partitions were looked up, so empty groups did not hit this.
kafka-consumer-groups filters out leaderless partitions before calling
listOffsets and still shows them with `-`. StreamsGroupService already has a
GroupOffsetsResetter, so we could reuse its `filterNoneLeaderPartitions` here.
##########
tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java:
##########
@@ -430,8 +430,8 @@ private void printStates(StreamsGroupDescription
description, boolean verbose) {
private void printOffsets(StreamsGroupDescription description, boolean
verbose) throws ExecutionException, InterruptedException {
Map<TopicPartition, OffsetsInfo> offsets = getOffsets(description);
- if (isGroupStateValid(description.groupState(),
description.members().size())) {
- maybePrintEmptyGroupState(description.groupId(),
description.groupState());
+ maybePrintEmptyGroupState(description.groupId(),
description.groupState());
+ if (isGroupStateValid(description.groupState(), offsets.size())) {
Review Comment:
This now counts offset rows instead of members, which matches
kafka-consumer-groups. In that case the consumer tool also prints `Warning:
Consumer group ... is rebalancing.` to stderr for ASSIGNING/RECONCILING, so the
empty output is explained. Should we do the same here, plus a similar notice
for NOT_READY? Fine as a follow-up too.
--
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]