You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/04 08:14:25 UTC

[GitHub] [flink] becketqin commented on a change in pull request #18610: [FLINK-23843][runtime] Properly fail the job when SplitEnumeratorContext.runInCoordinatorThread() throws an exception

becketqin commented on a change in pull request #18610:
URL: https://github.com/apache/flink/pull/18610#discussion_r819351084



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java
##########
@@ -257,9 +257,23 @@ public void signalNoMoreSplits(int subtask) {
         notifier.notifyReadyAsync(callable, handler);
     }
 
+    /** {@inheritDoc} If the runnable throws an Exception, the corresponding job is failed. */
     @Override
     public void runInCoordinatorThread(Runnable runnable) {
-        coordinatorExecutor.execute(runnable);
+        coordinatorExecutor.execute(wrap(runnable));
+    }
+
+    private Runnable wrap(final Runnable runnable) {
+        return () -> {
+            try {
+                runnable.run();
+            } catch (final Throwable t) {
+                // when using a SheduledThreadPool, uncaught exception handler catches only
+                // exceptions thrown by the threadPool, so manually call it when the exception is
+                // thrown by the runnable
+                coordinatorThreadFactory.uncaughtException(Thread.currentThread(), t);

Review comment:
       The interface was changed due to [FLIP-182](https://cwiki.apache.org/confluence/display/FLINK/FLIP-182%3A+Support+watermark+alignment+of+FLIP-27+Sources), which schedules a watermark synchronization runnable in the coordinator executor. And the `scheduleAtFixedRate()` method resides in `ScheduledExecutorService`.




-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org