lucasbru commented on code in PR #15511:
URL: https://github.com/apache/kafka/pull/15511#discussion_r1522964906
##########
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 think the server is bumping the target member epoch when any assignment
for any member changes, while the local epoch is only bumped if the assignment
for this specific member changes. So we should get fewer reconciliations.
--
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]