[ https://issues.apache.org/jira/browse/KAFKA-19675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18018380#comment-18018380 ]
Lianet Magrans commented on KAFKA-19675: ---------------------------------------- Hey, in case it helps, assuming the contract for onTaskAssigned is the same as onPartitionsAssigned, it should only be triggered within a call to poll, so we don't want it triggered on close even if there is a pending event for it (so this log you shared would be expected, in the case where close happens when there is a callback needed event in the queue but no poll before closing) Note that on the consumer there is no processing of background events on close, intentionally, as we don't want to be triggering all callbacks or processing more errors. On close it's just the onPartitionsREvoked/Lost that are expected, so they are simply triggered directly on the app thread ([https://github.com/apache/kafka/blob/b92d47d48791dc379d67239489fcf1bf8016b6b1/clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java#L1481] ) Not sure about the contract regarding streams callbacks, but if it's the same as with the consumer callbacks, we probably just need to ensure that the streamsTaskRevoked/Lost are triggered on close I would expect. > StreamsOnTasksAssignedCallbackNeededEvent could not be completed > ------------------------------------------------------------------ > > Key: KAFKA-19675 > URL: https://issues.apache.org/jira/browse/KAFKA-19675 > Project: Kafka > Issue Type: Sub-task > Reporter: Lucas Brutschy > Priority: Major > > In several tests, for example PlaintextAdminIntegrationTest, we see this > exception silently triggered when the consumer is closed. > > {code:java} > org.apache.kafka.common.errors.TimeoutException: > StreamsOnTasksAssignedCallbackNeededEvent could not be completed before the > consumer closed[2025-09-05 14:17:40,972] ERROR [Consumer > clientId=consumer-stream_group_id_1-1, groupId=stream_group_id_1] > Reconciliation failed: callback invocation failed for tasks > LocalAssignment{localEpoch=0, activeTasks={subtopology-0=[0, 1, 2]}, > standbyTasks={}, warmupTasks={}} > (org.apache.kafka.clients.consumer.internals.StreamsMembershipManager:1077)java.util.concurrent.CompletionException: > org.apache.kafka.common.errors.TimeoutException: > StreamsOnTasksAssignedCallbackNeededEvent could not be completed before the > consumer closed at > java.base/java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:368) > at > java.base/java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:377) > at > java.base/java.util.concurrent.CompletableFuture$UniRelay.tryFire(CompletableFuture.java:1097) > at > java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) > at > java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162) > at > org.apache.kafka.clients.consumer.internals.events.CompletableEventReaper.completeEventsExceptionallyOnClose(CompletableEventReaper.java:202) > at > org.apache.kafka.clients.consumer.internals.events.CompletableEventReaper.reap(CompletableEventReaper.java:149) > at > org.apache.kafka.clients.consumer.internals.AsyncKafkaConsumer.close(AsyncKafkaConsumer.java:1493) > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)