davidradl commented on code in PR #26861:
URL: https://github.com/apache/flink/pull/26861#discussion_r2273529568


##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java:
##########
@@ -885,6 +850,53 @@ else if (transitionState(current, ExecutionState.FAILED, 
t)) {
         }
     }
 
+    /**
+     * Transition into our final state in case of failure. We should be either 
in DEPLOYING,
+     * INITIALIZING, RUNNING, CANCELING, or FAILED loop for multiple retries 
during concurrent state
+     * changes via calls to cancel() or to failExternally()
+     */
+    private void transitionStateOnFailure(
+            Throwable t, AutoCloseableRegistry postFailureCleanUpRegistry) 
throws IOException {
+        while (true) {
+            ExecutionState current = this.executionState;
+
+            if (current == ExecutionState.RUNNING
+                    || current == ExecutionState.INITIALIZING
+                    || current == ExecutionState.DEPLOYING) {
+                if (ExceptionUtils.findThrowable(t, 
CancelTaskException.class).isPresent()) {
+                    if (transitionState(current, ExecutionState.CANCELED, t)) {
+                        postFailureCleanUpRegistry.registerCloseable(
+                                () -> cancelInvokable(invokable));
+                        break;
+                    }
+                } else {
+                    if (transitionState(current, ExecutionState.FAILED, t)) {
+                        postFailureCleanUpRegistry.registerCloseable(
+                                () -> cancelInvokable(invokable));
+                        break;
+                    }
+                }
+            } else if (current == ExecutionState.CANCELING) {
+                if (transitionState(current, ExecutionState.CANCELED)) {
+                    break;
+                }
+            } else if (current == ExecutionState.FAILED) {
+                // in state failed already, no transition necessary any more
+                break;
+            }
+            // unexpected state, go to failed
+            else if (transitionState(current, ExecutionState.FAILED, t)) {
+                LOG.error(
+                        "Unexpected state in task {} ({}) during an exception: 
{}.",
+                        taskNameWithSubtask,
+                        executionId,
+                        current);
+                break;
+            }
+            // else fall through the loop and

Review Comment:
   sentence unfinished



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

Reply via email to