mjsax commented on code in PR #23597:
URL: https://github.com/apache/kafka/pull/23597#discussion_r4498537954


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/TargetAssignmentBuilder.java:
##########
@@ -289,6 +293,72 @@ public TargetAssignmentResult build() throws 
TaskAssignorException {
         return new TargetAssignmentResult(records, newTargetAssignment);
     }
 
+    private void validateAssignment(Map<String, 
org.apache.kafka.coordinator.group.streams.TasksTuple> assignment) {
+        // The builder produces empty assignments when the topology is not 
ready.
+        if (!topology.isReady()) {
+            return;
+        }
+
+        final Map<String, ConfiguredSubtopology> subtopologies = 
topology.subtopologies().orElseThrow();
+        final Map<TaskId, String> activeOwners = new HashMap<>();
+        final Map<String, Map<TaskId, String>> processOwners = new HashMap<>();
+
+        assignment.forEach((memberId, memberAssignment) -> {
+            final String processId = members.get(memberId).processId();
+            final Map<TaskId, String> ownersOnProcess = 
processOwners.computeIfAbsent(processId, ignored -> new HashMap<>());
+
+            for (TaskRole role : List.of(TaskRole.ACTIVE, TaskRole.STANDBY)) {
+                final Map<String, Set<Integer>> tasks = role == TaskRole.ACTIVE
+                    ? memberAssignment.activeTasks() : 
memberAssignment.standbyTasks();
+
+                tasks.forEach((subtopologyId, partitions) -> {
+                    // Both active and standby tasks must reference a 
subtopology in the configured topology.
+                    ConfiguredSubtopology subtopology = 
subtopologies.get(subtopologyId);
+                    if (subtopology == null) {
+                        throw new TaskAssignorException(String.format(

Review Comment:
   Not sure if throwing this exception is right? Won't it kill the GC/broker?
   
   The fall back should maybe be, to stay on the previous assignment? -- At 
least this is what we do elsewhere IIRC, even if I am not sure if it's the best 
strategy? Assume a member left the group: for this case, we would get offline 
partitions/tasks which are not assigned.
   
    \cc @lucasbru @dajac 



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