brandboat commented on code in PR #20708:
URL: https://github.com/apache/kafka/pull/20708#discussion_r2435845520
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:
##########
@@ -385,10 +386,25 @@ void resetOffsets() {
if
(!(GroupState.EMPTY.equals(shareGroupDescription.groupState()) ||
GroupState.DEAD.equals(shareGroupDescription.groupState()))) {
CommandLineUtils.printErrorAndExit(String.format("Share
group '%s' is not empty.", groupId));
}
- Map<TopicPartition, OffsetAndMetadata> offsetsToReset =
prepareOffsetsToReset(groupId);
- if (offsetsToReset == null) {
- return;
+ resetOffsetsForInactiveGroup(groupId);
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
+ } catch (ExecutionException ee) {
+ Throwable cause = ee.getCause();
+ if (cause instanceof GroupIdNotFoundException) {
+ resetOffsetsForInactiveGroup(groupId);
Review Comment:
I think this PR aims to align the behavior between consumer groups and
shared consumer groups.
For regular consumer groups, we already have similar logic — if the group
doesn’t exist, it will be automatically created. see
https://github.com/apache/kafka/blob/fd9b5514add07628c5df5993c9ac7c494942a16a/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java#L465-L466
In this PR, the shared consumer group now follows the same behavior:
https://github.com/apache/kafka/pull/20708/files#diff-00f0f81cf13e66781777d94f7d2e68a581663385c37e98792507f2294c91bb09R8309-R8310
Back to your question, I think your understanding is correct. This is
something like a retry mechanism: if describeShareGroups throws a
`GroupIdNotFoundException`, then will call `resetOffsetsForInactiveGroup`
again, which will implicitly create the shared group.
Perhaps Andrew can elaborate more 😃
--
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]