metaswirl commented on a change in pull request #18689:
URL: https://github.com/apache/flink/pull/18689#discussion_r803739789



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/StopWithSavepoint.java
##########
@@ -134,30 +143,53 @@ public JobStatus getJobStatus() {
         return JobStatus.RUNNING;
     }
 
+    private void handleFailure(Failure failure) {
+        failureCollection.add(failure);
+        FailureResult failureResult = context.howToHandleFailure(failure);
+        transitionOnFailure(failureResult);
+    }
+
     @Override
     public void handleGlobalFailure(Throwable cause) {
-        handleAnyFailure(cause);
+        handleFailure(Failure.createGlobal(cause));
     }
 
     @Override
     boolean updateTaskExecutionState(TaskExecutionStateTransition 
taskExecutionStateTransition) {
         final boolean successfulUpdate =
                 getExecutionGraph().updateState(taskExecutionStateTransition);
 
-        if (successfulUpdate) {
-            if (taskExecutionStateTransition.getExecutionState() == 
ExecutionState.FAILED) {
-                Throwable cause = 
taskExecutionStateTransition.getError(userCodeClassLoader);
-                handleAnyFailure(
-                        cause == null
-                                ? new FlinkException(
-                                        "Unknown failure cause. Probably 
related to FLINK-21376.")
-                                : cause);
-            }
+        if (successfulUpdate
+                && taskExecutionStateTransition.getExecutionState() == 
ExecutionState.FAILED) {
+            handleFailure(
+                    Failure.createLocal(
+                            extractError(taskExecutionStateTransition),
+                            
extractExecutionVertexID(taskExecutionStateTransition)));
         }
 
         return successfulUpdate;
     }
 
+    private void transitionOnFailure(FailureResult failureResult) {

Review comment:
       It's only used in two of five states. Placing it into 
`StateWithExecutionGraph` doesn't seem right. Also, my rule of thumb is, to 
only abstract it away when it occurs at least three times. 
(https://andrewbrookins.com/technology/the-rule-of-three/)  




-- 
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-unsubscr...@flink.apache.org

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


Reply via email to