lianetm commented on code in PR #15511:
URL: https://github.com/apache/kafka/pull/15511#discussion_r1523880045
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImpl.java:
##########
@@ -508,9 +508,30 @@ private void
processAssignmentReceived(ConsumerGroupHeartbeatResponseData.Assign
*/
private void replaceTargetAssignmentWithNewAssignment(
ConsumerGroupHeartbeatResponseData.Assignment assignment) {
- currentTargetAssignment.clear();
+
+ // Return if the same as current assignment; comparison without
creating a new collection
+ if (currentTargetAssignment != null) {
+ // check if the new assignment is different from the current
target assignment
+ if (currentTargetAssignment.partitions.size() ==
assignment.topicPartitions().size() &&
+ assignment.topicPartitions().stream().allMatch(
+ tp ->
currentTargetAssignment.partitions.containsKey(tp.topicId()) &&
+
currentTargetAssignment.partitions.get(tp.topicId()).size() ==
tp.partitions().size() &&
+
currentTargetAssignment.partitions.get(tp.topicId()).containsAll(tp.partitions())))
{
+ return;
+ }
+ }
+
+ // Bump local epoch and replace assignment
+ long nextLocalEpoch;
+ if (currentTargetAssignment == null) {
+ nextLocalEpoch = 0;
+ } else {
+ nextLocalEpoch = currentTargetAssignment.localEpoch + 1;
+ }
Review Comment:
I was wrong thinking that we could reuse the server epoch here, but it's not
truly representing new assignments for the member, and we could end up
receiving multiple new assignments in the same server epoch. So ok with this
local epoch approach, best way to keep track of "versions" of the assignment
received.
--
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]