You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "lucasbru (via GitHub)" <gi...@apache.org> on 2026/10/28 19:13:10 UTC

[PR] MINOR: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

lucasbru opened a new pull request, #24003:
URL: https://github.com/apache/kafka/pull/24003

   The group coordinator returns `ASSIGNMENT_DELAYED` in two situations: during the initial rebalance delay of a new streams group, and when it defers computing a new target assignment because the configured assignment interval has not elapsed yet. In the second case the member keeps its current assignment, but `StreamsMembershipManager` mapped the status to `isGroupReady=false`. The membership manager then re-reconciled the unchanged tasks as not ready, and `StreamThread` skipped processing, committing and punctuating for all owned tasks until a later heartbeat (up to one heartbeat interval) no longer carried the status.
   
   With this change, `ASSIGNMENT_DELAYED` on its own keeps the readiness of the previous target assignment. Since the target assignment starts out not ready and is reset when the member leaves or is fenced, a member that has not been ready yet, including one waiting out the initial rebalance delay, still does not enter `RUNNING` with an empty assignment. A ready member keeps processing the tasks it owns. Missing or incorrectly partitioned topics still mark the group as not ready, also when reported together with `ASSIGNMENT_DELAYED`.
   
   The new unit tests in `StreamsMembershipManagerTest` reproduce the issue (a ready member owning a task receiving a second tasks-assigned event with `isGroupReady=false`) and cover the combination with a missing-topics status. The existing test for a ready/not-ready transition without task changes now uses `MISSING_SOURCE_TOPICS`, since it previously asserted the behaviour being fixed.
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-21389: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

Posted by "lucasbru (via GitHub) via jira" <ji...@kafka.apache.org>.
lucasbru commented on code in PR #24003:
URL: https://github.com/apache/kafka/pull/24003#discussion_r4597130463


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:
##########
@@ -804,21 +804,31 @@ public void onHeartbeatSuccess(StreamsGroupHeartbeatResponse response) {
         }
     }
 
+    /**
+     * Determines whether the group is ready from the statuses of a heartbeat response.
+     * <p>
+     * {@code ASSIGNMENT_DELAYED} only means that the coordinator deferred computing a new target assignment, so it
+     * keeps the previous readiness: a member that has not yet been ready (e.g., during the initial rebalance delay)
+     * stays not ready, while a ready member keeps processing the tasks it owns.
+     */
     private boolean isGroupReady(List<StreamsGroupHeartbeatResponseData.Status> statuses) {
+        boolean assignmentDelayed = false;
         if (statuses != null) {
             for (final StreamsGroupHeartbeatResponseData.Status status : statuses) {
                 switch (StreamsGroupHeartbeatResponse.Status.fromCode(status.statusCode())) {
                     case MISSING_SOURCE_TOPICS:
                     case MISSING_INTERNAL_TOPICS:
                     case INCORRECTLY_PARTITIONED_TOPICS:
-                    case ASSIGNMENT_DELAYED:
                         return false;
+                    case ASSIGNMENT_DELAYED:
+                        assignmentDelayed = true;
+                        break;
                     default:
                         // continue checking other statuses
                 }
             }
         }
-        return true;
+        return !assignmentDelayed || targetAssignment.isGroupReady;

Review Comment:
   Done, it's an if/else now.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-21389: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

Posted by "lucasbru (via GitHub) via jira" <ji...@kafka.apache.org>.
lucasbru merged PR #24003:
URL: https://github.com/apache/kafka/pull/24003


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-21389: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on PR #24003:
URL: https://github.com/apache/kafka/pull/24003#issuecomment-6500555012

   This depends on #23991. With this change the delayed-assignment stall no longer masks that a warm-up task on an empty changelog never reports an end offset, so `StreamsGroupWarmupTaskLifecycleIntegrationTest.shouldGiveUpAWarmupTaskTheTargetAssignmentNoLongerWantsOnScaleIn` fails until that is merged. I'll rebase once it is in.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-21389: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

Posted by "mjsax (via GitHub) via jira" <ji...@kafka.apache.org>.
mjsax commented on code in PR #24003:
URL: https://github.com/apache/kafka/pull/24003#discussion_r4593783257


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManager.java:
##########
@@ -804,21 +804,31 @@ public void onHeartbeatSuccess(StreamsGroupHeartbeatResponse response) {
         }
     }
 
+    /**
+     * Determines whether the group is ready from the statuses of a heartbeat response.
+     * <p>
+     * {@code ASSIGNMENT_DELAYED} only means that the coordinator deferred computing a new target assignment, so it
+     * keeps the previous readiness: a member that has not yet been ready (e.g., during the initial rebalance delay)
+     * stays not ready, while a ready member keeps processing the tasks it owns.
+     */
     private boolean isGroupReady(List<StreamsGroupHeartbeatResponseData.Status> statuses) {
+        boolean assignmentDelayed = false;
         if (statuses != null) {
             for (final StreamsGroupHeartbeatResponseData.Status status : statuses) {
                 switch (StreamsGroupHeartbeatResponse.Status.fromCode(status.statusCode())) {
                     case MISSING_SOURCE_TOPICS:
                     case MISSING_INTERNAL_TOPICS:
                     case INCORRECTLY_PARTITIONED_TOPICS:
-                    case ASSIGNMENT_DELAYED:
                         return false;
+                    case ASSIGNMENT_DELAYED:
+                        assignmentDelayed = true;
+                        break;
                     default:
                         // continue checking other statuses
                 }
             }
         }
-        return true;
+        return !assignmentDelayed || targetAssignment.isGroupReady;

Review Comment:
   While correct, I find this personally hard to read... What do you think about changing it to
   ```
     if (assignmentDelayed) {                                                                                                                                                                                                    
         return targetAssignment.isGroupReady;                                                                                                                                                                                   
     } else {                                                                                                                                                                                                                    
         return true;                                                                                                                                                                                                            
     } 
   ```
   
   Atm it reads like a "double negation" bending my mind...



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on code in PR #24003:
URL: https://github.com/apache/kafka/pull/24003#discussion_r4410289673


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManagerTest.java:
##########
@@ -2487,6 +2487,68 @@ public void testIsGroupReadyChangeWhenTasksAreNull() {
         completeAssignment(tasksAssignedEvent2);
     }
 
+    @Test
+    public void testAssignmentDelayedKeepsReadyGroupReady() {

Review Comment:
   Agreed, both are worth pinning down. Added `testAssignmentDelayedWhileReconcilingKeepsTargetReady` / `...KeepsTargetNotReady` for the pending-callback case in both directions (both fail if the readiness is taken from `currentAssignment`), and `testAssignmentDelayedWithUnchangedAssignmentKeepsStableMemberReady` for the echoed assignment while `STABLE`, which also fails without the fix.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Keep a ready streams member ready on ASSIGNMENT_DELAYED [kafka]

Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #24003:
URL: https://github.com/apache/kafka/pull/24003#discussion_r4407160115


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/StreamsMembershipManagerTest.java:
##########
@@ -2487,6 +2487,68 @@ public void testIsGroupReadyChangeWhenTasksAreNull() {
         completeAssignment(tasksAssignedEvent2);
     }
 
+    @Test
+    public void testAssignmentDelayedKeepsReadyGroupReady() {

Review Comment:
   Could we add two more test cases to cover the readiness preservation here?
   - `ASSIGNMENT_DELAYED` while an assignment callback is pending. Start with `currentAssignment.isGroupReady != targetAssignment.isGroupReady`, receive a delayed response, then complete the pending callback and generate the ACK. Verify that the latest target readiness is preserved, with no additional assignment callback. Covering both directions would distinguish the intended behavior from accidentally using `currentAssignment.isGroupReady`; the current tests have already completed reconciliation when the delayed response arrives.
   - `ASSIGNMENT_DELAYED` with a non-null, unchanged assignment while `STABLE`. Complete reconciliation, generate the `ACK` to transition to `STABLE`, then receive the delayed response with the same task sets. Verify that the member stays ready and `STABLE` without another assignment callback. This matches a possible broker response: it echoes the assignment when owned tasks are reported, even while computing the next target assignment is delayed.
   
   What do you think? 



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org