chia7712 commented on code in PR #17440: URL: https://github.com/apache/kafka/pull/17440#discussion_r1860952945
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java: ########## @@ -153,7 +154,16 @@ void runOnce() { .map(rm -> rm.maximumTimeToWait(currentTimeMs)) .reduce(Long.MAX_VALUE, Math::min); - reapExpiredApplicationEvents(currentTimeMs); + List<CompletableEvent<?>> completableEvents = reapExpiredApplicationEvents(currentTimeMs); + + // If there is a metadata error, complete the completable events which are not passed by error event with the metadata error + if (networkClientDelegate.metadataError().isPresent()) { + Throwable metadataError = networkClientDelegate.metadataError().get(); + completableEvents.stream() + .filter(event -> !(event instanceof CompletableApplicationEvent && ((CompletableApplicationEvent<?>) event).isPassedByErrorEvent())) + .forEach(event -> event.future().completeExceptionally(metadataError)); + networkClientDelegate.clearMetadataError(); Review Comment: > so they will never fail with the metadata error because we would call completeExceptionally on a future that is already complete right? That makes sense. We could encounter a metadata error while processing the last event, and we should use that error to complete all application events at the beginning of the next loop. -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org