frankvicky commented on code in PR #23266:
URL: https://github.com/apache/kafka/pull/23266#discussion_r3913380248
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinatorTest.java:
##########
@@ -712,7 +713,7 @@ public void
testNoGenerationWillNotTriggerProtocolNameCheck() {
if (!(body instanceof SyncGroupRequest)) {
return false;
}
- coordinator.resetGenerationOnLeaveGroup();
+ coordinator.resetStateAndRejoin("clear generation before the sync
response is handled", true);
Review Comment:
Could we leverage `resetStateOnResponseError` instead of
`resetStateAndRejoin`?
In this way, we don't need to expose the `resetStateAndRejoin`
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractCoordinator.java:
##########
@@ -1180,7 +1177,13 @@ public synchronized RequestFuture<Void>
maybeLeaveGroup(CloseOptions.GroupMember
client.pollNoWakeup();
}
- resetGenerationOnLeaveGroup();
+ // A static member whose LeaveGroup is suppressed stays registered
with the group
+ // coordinator under its current member id, so keep the id locally as
well: resetting
+ // it would make the next rejoin carry UNKNOWN_MEMBER_ID, which the
coordinator must
+ // treat as a new instance claiming this group.instance.id, fencing
any still-pending
+ // join attempt of this same consumer (KAFKA-20985). State and
generation are reset
+ // and a rejoin is requested exactly as before.
+ resetStateAndRejoin("consumer pro-actively leaving the group",
shouldSendLeaveGroup || isDynamicMember());
Review Comment:
I think it would be more clear to do like this:
```suggestion
boolean shouldKeepMemberId = !shouldSendLeaveGroup &&
!isDynamicMember()
resetStateAndRejoin("consumer pro-actively leaving the group",
shouldKeepMemberId);
```
--
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]