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

[PR] KAFKA-20598: Prevent polling unassigned consumer during ConsumerTask shutdown [kafka]

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

   This PR fixes a `ConsumerTask` shutdown race by skipping poll once the task is closed before partition assignment, preventing the spurious “consumer not subscribed/assigned” error.


-- 
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-20598: Prevent polling unassigned consumer during ConsumerTask shutdown [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #22328:
URL: https://github.com/apache/kafka/pull/22328#issuecomment-4551334334

   A label of 'needs-attention' was automatically added to this PR in order to raise the
   attention of the committers. Once this issue has been triaged, the `triage` label
   should be removed to prevent this automation from happening again.


-- 
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-20598: Prevent polling unassigned consumer during ConsumerTask shutdown [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #22328:
URL: https://github.com/apache/kafka/pull/22328


-- 
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-20598: Prevent polling unassigned consumer during ConsumerTask shutdown [kafka]

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


##########
storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerTaskTest.java:
##########
@@ -104,6 +112,20 @@ public void testCloseOnNoAssignment() {
         assertDoesNotThrow(() -> consumerTask.closeConsumer(), "CloseConsumer method threw exception");
     }
 
+    @Test
+    public void testCloseBeforeAssignmentDoesNotPollConsumer() {
+        final Consumer<byte[], byte[]> mockConsumer = mock(Consumer.class);
+        when(mockConsumer.poll(any(Duration.class)))

Review Comment:
   ```java
           when(mockConsumer.poll(any(Duration.class)))
               .thenThrow(new AssertionError("poll() should not be called when ConsumerTask is closed before any partition assignment"));
   ```
   this is unnecessary due to following verify, right?



-- 
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-20598: Prevent polling unassigned consumer during ConsumerTask shutdown [kafka]

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


##########
storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerTaskTest.java:
##########
@@ -104,6 +112,20 @@ public void testCloseOnNoAssignment() {
         assertDoesNotThrow(() -> consumerTask.closeConsumer(), "CloseConsumer method threw exception");
     }
 
+    @Test
+    public void testCloseBeforeAssignmentDoesNotPollConsumer() {
+        final Consumer<byte[], byte[]> mockConsumer = mock(Consumer.class);
+        when(mockConsumer.poll(any(Duration.class)))

Review Comment:
   Good catch, it was redundant with the `verify(..., never())` below. Removed, Thanks!



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