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/10/24 11:05:18 UTC

[GitHub] [flink] yunfengzhou-hub commented on a diff in pull request #20454: [FLINK-28639][Runtime/Checkpointing] Preserve consistency of events from subtask to OC

yunfengzhou-hub commented on code in PR #20454:
URL: https://github.com/apache/flink/pull/20454#discussion_r1003186637


##########
flink-runtime/src/main/java/org/apache/flink/runtime/operators/coordination/OperatorCoordinatorHolder.java:
##########
@@ -207,25 +241,43 @@ public void close() throws Exception {
     public void handleEventFromOperator(int subtask, int attemptNumber, OperatorEvent event)
             throws Exception {
         mainThreadExecutor.assertRunningInMainThread();
-        if (event instanceof AcknowledgeCheckpointEvent) {
+
+        if (event instanceof AcknowledgeCloseGatewayEvent) {
+            Preconditions.checkArgument(
+                    subtask == ((AcknowledgeCloseGatewayEvent) event).getSubtaskIndex());
+            completeAcknowledgeCloseGatewayFuture(
+                    ((AcknowledgeCloseGatewayEvent) event).getCheckpointID(), subtask);
+            return;
+        } else if (event instanceof OpenGatewayEvent) {
+            Preconditions.checkArgument(subtask == ((OpenGatewayEvent) event).getSubtaskIndex());
             subtaskGatewayMap
                     .get(subtask)
-                    .openGatewayAndUnmarkCheckpoint(
-                            ((AcknowledgeCheckpointEvent) event).getCheckpointID());
+                    .openGatewayAndUnmarkCheckpoint(((OpenGatewayEvent) event).getCheckpointID());
             return;
         }
+
         coordinator.handleEventFromOperator(subtask, attemptNumber, event);
     }
 
     public void executionAttemptFailed(int subtask, int attemptNumber, @Nullable Throwable reason) {
         mainThreadExecutor.assertRunningInMainThread();
+
+        if (!context.isConcurrentExecutionAttemptsSupported()) {
+            abortAcknowledgeCloseGatewayFutures(
+                    x -> x.f1 == subtask, String.format("Subtask %d has failed.", subtask), reason);
+        }
+
         coordinator.executionAttemptFailed(subtask, attemptNumber, reason);
     }
 
     @Override
     public void subtaskReset(int subtask, long checkpointId) {
         mainThreadExecutor.assertRunningInMainThread();
 
+        if (!context.isConcurrentExecutionAttemptsSupported()) {
+            checkNoSuchAcknowledgeCloseGatewayFutures(x -> x.f1 == subtask);

Review Comment:
   You are right. I had assumed that `sutaskReset` would always be invoked after `executionAttemptFailed`, while this is not guaranteed by JavaDoc. I'll change it to `abortAcknowledgeCloseGatewayFutures`.



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