[
https://issues.apache.org/jira/browse/FLINK-6833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16041755#comment-16041755
]
ASF GitHub Bot commented on FLINK-6833:
---------------------------------------
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/4058#discussion_r120757786
--- Diff:
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
---
@@ -824,11 +824,14 @@ public ProcessingTimeService
getProcessingTimeService() {
* FAILED, and, if the invokable code is running, starts an
asynchronous thread
* that aborts that code.
*
- * <p>This method never blocks.</p>
+ * <p>This method never blocks.
*/
@Override
public void handleAsyncException(String message, Throwable exception) {
- getEnvironment().failExternally(exception);
+ if (isRunning) {
--- End diff --
If `isRunning == true` when entering the if branch, then depending on what
happens before `failExternally`, we can assume that the `handleAsyncException`
either happened atomically before `isRunning` was set to `false` or not. But
what we don't want to happen is that if `isRunning == false`, that we can still
fail the task. Thus, I think it solves a valid problem.
> Race condition: Asynchronous checkpointing task can fail completed StreamTask
> -----------------------------------------------------------------------------
>
> Key: FLINK-6833
> URL: https://issues.apache.org/jira/browse/FLINK-6833
> Project: Flink
> Issue Type: Bug
> Components: Local Runtime, State Backends, Checkpointing
> Affects Versions: 1.3.0, 1.4.0
> Reporter: Till Rohrmann
> Assignee: Till Rohrmann
> Priority: Critical
>
> A {{StreamTask}} which is about to finish and thus transitioning its
> containing {{Task}} into the {{ExecutionState.FINISHED}} state, can be failed
> by a concurrent asynchronous checkpointing operation. The problem is that
> upon termination the {{StreamTask}} cancels all concurrent operations
> (amongst others ongoing asynchronous checkpoints). The cancellation of the
> async checkpoint triggers the {{StreamTask#handleAsyncException}} call which
> will fail the containing {{Task}}. If the {{handleAsyncException}} completes
> before the {{StreamTask}} has been properly terminated, then the containing
> {{Task}} will transition into {{ExecutionState.FAILED}} instead of
> {{ExecutionState.FINISHED}}.
> In order to resolve this race condition, we should check in the
> {{StreamTask#handleAsyncException}} whether the {{StreamTask}} is still
> running or has already been terminated. Only in the former case, we should
> fail the containing {{Task}}.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)