azagrebin commented on a change in pull request #7757: [FLINK-11630] Triggers 
the termination of all running Tasks when shutting down TaskExecutor
URL: https://github.com/apache/flink/pull/7757#discussion_r282888225
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
 ##########
 @@ -348,19 +352,26 @@ private void 
handleStartTaskExecutorServicesException(Exception e) throws Except
                resourceManagerHeartbeatManager.stop();
 
                try {
-                       stopTaskExecutorServices();
+                       CompletableFuture<Void> onStopFuture = 
stopTaskExecutorServices(failingTaskFutures);
+                       log.info("Stopped TaskExecutor {}.", getAddress());
+                       return onStopFuture;
                } catch (Exception e) {
                        throwable = ExceptionUtils.firstOrSuppressed(e, 
throwable);
-               }
-
-               if (throwable != null) {
                        return FutureUtils.completedExceptionally(new 
FlinkException("Error while shutting the TaskExecutor down.", throwable));
-               } else {
-                       log.info("Stopped TaskExecutor {}.", getAddress());
-                       return CompletableFuture.completedFuture(null);
                }
        }
 
+       private void failTasks(List<CompletableFuture<Void>> failingTaskFutures,
+                       JobManagerConnection jobManagerConnection,
+                       Throwable cause) {
+               Iterator<Task> tasks = 
taskSlotTable.getTasks(jobManagerConnection.getJobID());
+               while (tasks.hasNext()) {
+                       try {
+                               
failingTaskFutures.add(tasks.next().failExternally(cause));
+                       } catch (IllegalStateException ignored) {}
 
 Review comment:
   Why is the exception ignored? Should we not rather add it?
   `failingTaskFutures.add(new 
CompletableFuture<>().completeExceptionally(ignored))`

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


With regards,
Apache Git Services

Reply via email to