You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "dajac (via GitHub)" <gi...@apache.org> on 2024/06/17 15:14:58 UTC

[PR] MINOR: Refactor GroupMetadataManager#consumerGroupHeartbeat and GroupMetadataManager#classicGroupJoinToConsumerGroup [kafka]

dajac opened a new pull request, #16371:
URL: https://github.com/apache/kafka/pull/16371

   This patch is an attempt to simplifying GroupMetadataManager#consumerGroupHeartbeat and GroupMetadataManager#classicGroupJoinToConsumerGroup by sharing more of the common logic. It slightly change how static members are replaced too. Now, we generate the records to replace the member and then we update the member if needed.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Refactor GroupMetadataManager#consumerGroupHeartbeat and GroupMetadataManager#classicGroupJoinToConsumerGroup [kafka]

Posted by "dongnuo123 (via GitHub)" <gi...@apache.org>.
dongnuo123 commented on code in PR #16371:
URL: https://github.com/apache/kafka/pull/16371#discussion_r1643119465


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -1555,69 +1538,52 @@ private CoordinatorResult<Void, CoordinatorRecord> classicGroupJoinToConsumerGro
         throwIfConsumerGroupIsFull(group, memberId);
         throwIfClassicProtocolIsNotSupported(group, memberId, request.protocolType(), protocols);
 
+        if (instanceId == null && isUnknownMember && JoinGroupRequest.requiresKnownMemberId(context.apiVersion())) {
+            // A dynamic member required a member id joins the group. Send back a response to call for another

Review Comment:
   nit: A dynamic member requiring a member id joins the group



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Refactor GroupMetadataManager#consumerGroupHeartbeat and GroupMetadataManager#classicGroupJoinToConsumerGroup [kafka]

Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on PR #16371:
URL: https://github.com/apache/kafka/pull/16371#issuecomment-2194754537

   @jolshan Thanks for your comments. I addressed them and updated the PR.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Refactor GroupMetadataManager#consumerGroupHeartbeat and GroupMetadataManager#classicGroupJoinToConsumerGroup [kafka]

Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on PR #16371:
URL: https://github.com/apache/kafka/pull/16371#issuecomment-2173685475

   @dongnuo123 Could you please take a look?


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Refactor GroupMetadataManager#consumerGroupHeartbeat and GroupMetadataManager#classicGroupJoinToConsumerGroup [kafka]

Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #16371:
URL: https://github.com/apache/kafka/pull/16371#discussion_r1657083140


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -1867,11 +1936,12 @@ private Assignment updateTargetAssignment(
                     .withTopicsImage(metadataImage.topics())
                     .addOrUpdateMember(updatedMember.memberId(), updatedMember);
 
-            if (staticMemberReplaced) {
+            String previousMemberId = group.staticMemberId(updatedMember.instanceId());

Review Comment:
   We check the member id associated to the instance id. If it is different from the member id of the current member, it means that the member was replaced. Using `member.memberId` does not work because it is the idea of the current member.



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java:
##########
@@ -1133,14 +1148,19 @@ public void testStaticMemberGetsBackAssignmentUponRejoin() {
             .build();
 
         List<CoordinatorRecord> expectedRecordsAfterRejoin = Arrays.asList(
+            // The previous member is deleted.
             CoordinatorRecordHelpers.newCurrentAssignmentTombstoneRecord(groupId, memberId2),
             CoordinatorRecordHelpers.newTargetAssignmentTombstoneRecord(groupId, memberId2),
             CoordinatorRecordHelpers.newMemberSubscriptionTombstoneRecord(groupId, memberId2),
-            CoordinatorRecordHelpers.newMemberSubscriptionRecord(groupId, expectedRejoinedMember),
+
+            // The previous member is replaced by the new one.

Review Comment:
   Correct. These are the records generated by `replaceMember`. There are a copy of the previous member but with a new member id, and new member epoch and a new previous member epoch.



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -1867,11 +1936,12 @@ private Assignment updateTargetAssignment(
                     .withTopicsImage(metadataImage.topics())
                     .addOrUpdateMember(updatedMember.memberId(), updatedMember);
 
-            if (staticMemberReplaced) {
+            String previousMemberId = group.staticMemberId(updatedMember.instanceId());

Review Comment:
   We check the member id associated to the instance id. If it is different from the member id of the current member, it means that the member was replaced. Using `member.memberId` does not work because it is the id of the current member.



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -1867,11 +1936,12 @@ private Assignment updateTargetAssignment(
                     .withTopicsImage(metadataImage.topics())
                     .addOrUpdateMember(updatedMember.memberId(), updatedMember);
 
-            if (staticMemberReplaced) {
+            String previousMemberId = group.staticMemberId(updatedMember.instanceId());

Review Comment:
   Added a comment.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org