kafka-jira mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [kafka] kamalcph commented on a change in pull request #10605: KAFKA-12726 prevent a stuck Task.stop() from blocking subsequent Task.stops()s
Date Thu, 29 Apr 2021 05:39:15 GMT

kamalcph commented on a change in pull request #10605:
URL: https://github.com/apache/kafka/pull/10605#discussion_r622746344



##########
File path: connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java
##########
@@ -839,7 +840,22 @@ private void stopTask(ConnectorTaskId taskId) {
             ClassLoader savedLoader = plugins.currentThreadLoader();
             try {
                 savedLoader = Plugins.compareAndSwapLoaders(task.loader());
-                task.stop();
+                CountDownLatch latch = new CountDownLatch(1);
+                new Thread() {
+                    @Override
+                    public void run() {
+                        task.stop();
+                        latch.countDown();
+                    }
+                }.start();
+                // Wait for thread to terminate, but not longer than timeout.
+                if (timeout <= 0) {

Review comment:
       nit: This if statement is not required. The countdown latch won't wait at all if the
timeout is <= 0.




-- 
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:
users@infra.apache.org



Mime
View raw message