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


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignorTest.java:
##########
@@ -1545,6 +1545,44 @@ public void 
shouldAssignTasksToProcessesReportingTaskOffsetsOnColdStartWithMulti
             mergeAllActiveTasks(result, "member2_1", "member2_2"));
     }
 
+    @Test
+    public void 
shouldAssignTaskToMemberWithLocalStateWhenAnotherMemberOfSameProcessIsAtQuota() 
{
+        final Map<String, Map<Integer, Long>> taskOffsets = 
Map.of("test-subtopology", Map.of(2, 100L));
+        // Equal offsets preserve insertion order, so the member already at 
quota is considered first.
+        final Map<String, MemberMetadataAndStateImpl> members = new 
LinkedHashMap<>();
+
+        // Both members of process1 report local state for task 2.
+        members.put("member1_1", new MemberMetadataAndStateImpl(
+            Optional.empty(),
+            Optional.empty(),
+            "process1",
+            Map.of(),
+            Map.of("test-subtopology", Set.of(0)),
+            Map.of(),
+            Map.of(),
+            taskOffsets,
+            Map.of()));
+        members.put("member1_2", createMemberMetadataWithOffsets("process1", 
taskOffsets));
+
+        // Member of process2 have no local state for task 2.
+        members.put("member2_1", createMemberMetadata("process2", 
Map.of("test-subtopology", Set.of(1)), Map.of(), Map.of()));
+        members.put("member2_2", createMemberMetadata("process2"));
+        members.put("member2_3", createMemberMetadata("process2"));
+
+        // Three tasks and five members give a quota of one. After retaining 
tasks 0 and 1, process2 has
+        // lower load (1/3) than process1 (1/2), so falling back to load 
balancing would always lose local state.
+        final GroupAssignment result = assignor.assign(
+            new GroupSpecImpl(members, AssignmentConfigsImpl.DEFAULT),

Review Comment:
   Good catch! 
   I've added a new commit to test standby quota.



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