chickenchickenlove commented on code in PR #22245:
URL: https://github.com/apache/kafka/pull/22245#discussion_r3325001655


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -4091,9 +4276,17 @@ private UpdateTargetAssignmentResult<TasksTuple> 
maybeUpdateStreamsTargetAssignm
                 .withMetadataImage(metadataImage)
                 .withTargetAssignment(group.targetAssignment());
 
-            updatedMember.ifPresent(member ->
-                assignmentResultBuilder.addOrUpdateMember(member.memberId(), 
member)
-            );
+            updatedMember.ifPresent(member -> {
+                assignmentResultBuilder.addOrUpdateMember(member.memberId(), 
member);
+                // If the instance id was associated to a different member, it 
means that the
+                // static member is replaced by the current member hence we 
remove the previous one.
+                member.instanceId().ifPresent(instanceId -> {
+                    StreamsGroupMember previousMember = 
group.staticMember(instanceId);
+                    if (previousMember != null && 
!member.memberId().equals(previousMember.memberId())) {
+                        
assignmentResultBuilder.removeMember(previousMember.memberId());
+                    }
+                });
+            });

Review Comment:
   No problem, thanks for the time to look into this 🙇‍♂️ 



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