XComp commented on a change in pull request #18610:
URL: https://github.com/apache/flink/pull/18610#discussion_r820245032
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContext.java
##########
@@ -257,9 +257,18 @@ 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);
+ // when using a SheduledThreadPool, uncaught exception handler catches
only
Review comment:
```suggestion
// when using a ScheduledThreadPool, uncaught exception handler
catches only
```
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContextTest.java
##########
@@ -155,6 +156,40 @@ private void testAssignSplitToUnregisterdReader(boolean
fromCoordinatorExecutor)
"Cannot assign splits");
}
+ @Test
+ public void testExceptionInRunnableFailsTheJob()
+ throws InterruptedException, ExecutionException {
+ ManuallyTriggeredScheduledExecutorService manualWorkerExecutor =
+ new ManuallyTriggeredScheduledExecutorService();
+ // need the factory to have the exception handler set
+ final ManuallyTriggeredScheduledExecutorService
coordinatorExecutorWithExceptionHandler =
+ new ManuallyTriggeredScheduledExecutorService();
+ SourceCoordinatorContext<MockSourceSplit> testingContext =
+ new SourceCoordinatorContext<>(
+ coordinatorExecutorWithExceptionHandler,
+ manualWorkerExecutor,
+ coordinatorThreadFactory,
+ operatorCoordinatorContext,
+ new MockSourceSplitSerializer(),
+ splitSplitAssignmentTracker);
+
+ testingContext.runInCoordinatorThread(
+ () -> {
+ throw new RuntimeException();
+ });
+
+ manualWorkerExecutor.triggerAll();
+ // testingContext.close(); already shutdowns coordinatorExecutor and
blocks until tasks are
+ // finished
+ testingContext.close();
+ coordinatorExecutorWithExceptionHandler.triggerAll();
+ // blocks until the job is failed :
+ // wait that the uncaught exception handler calls
operatorCoordinatorContext#failJob which
+ // completes the future
Review comment:
```suggestion
// blocks until the job is failed: wait that the uncaught exception
handler calls
// operatorCoordinatorContext#failJob which completes the future
```
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorContextTest.java
##########
@@ -155,6 +156,40 @@ private void testAssignSplitToUnregisterdReader(boolean
fromCoordinatorExecutor)
"Cannot assign splits");
}
+ @Test
+ public void testExceptionInRunnableFailsTheJob()
+ throws InterruptedException, ExecutionException {
+ ManuallyTriggeredScheduledExecutorService manualWorkerExecutor =
+ new ManuallyTriggeredScheduledExecutorService();
+ // need the factory to have the exception handler set
+ final ManuallyTriggeredScheduledExecutorService
coordinatorExecutorWithExceptionHandler =
+ new ManuallyTriggeredScheduledExecutorService();
+ SourceCoordinatorContext<MockSourceSplit> testingContext =
+ new SourceCoordinatorContext<>(
+ coordinatorExecutorWithExceptionHandler,
+ manualWorkerExecutor,
+ coordinatorThreadFactory,
+ operatorCoordinatorContext,
+ new MockSourceSplitSerializer(),
+ splitSplitAssignmentTracker);
+
+ testingContext.runInCoordinatorThread(
+ () -> {
+ throw new RuntimeException();
+ });
+
+ manualWorkerExecutor.triggerAll();
+ // testingContext.close(); already shutdowns coordinatorExecutor and
blocks until tasks are
+ // finished
Review comment:
```suggestion
// already shutdowns coordinatorExecutor and blocks until tasks are
finished
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]