C0urante commented on a change in pull request #10016: URL: https://github.com/apache/kafka/pull/10016#discussion_r568603419
########## File path: connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSourceTask.java ########## @@ -202,6 +198,8 @@ public void removeMetrics() { public void cancel() { super.cancel(); offsetReader.close(); + // Run on a separate thread to avoid potentially blocking the herder thread + new Thread(() -> closeProducer(0)).start(); Review comment: Yeah, we can probably use an executor for this. I was on the fence about the necessity of doing this in a separate thread at all (hence the half-assing here) but then I looked deeper into the `KafkaProducer::close` logic and saw that that included closing its interceptors, key serializer, value serializer, etc. Any time user code is called we should assume it can block forever (probably worth adding as a comment here), so yeah, since I'm more confident in the necessity of asynchronously closing the producer I'll expand this to use an executor. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org