rkhachatryan commented on a change in pull request #14186:
URL: https://github.com/apache/flink/pull/14186#discussion_r529465290



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java
##########
@@ -1369,7 +1408,8 @@ private boolean restoreLatestCheckpointedStateInternal(
                                        allowNonRestoredState,
                                        LOG);
 
-                       if (restoreCoordinators) {
+                       if (coordinatorRestoreBehavior == 
CoordinatorRestore.ALWAYS ||
+                                       coordinatorRestoreBehavior == 
CoordinatorRestore.ONLY_FOR_EXISTING_CHECKPOINT) {

Review comment:
       nit: how about `if (coordinatorRestoreBehavior.restoreState()) {`?

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java
##########
@@ -1869,4 +1908,16 @@ public boolean isForce() {
                        return props.forceCheckpoint();
                }
        }
+
+       private enum CoordinatorRestore {

Review comment:
       nit: the argument of this type is named `coordinatorRestoreBehavior` 
above. I think it makes sense to add "Behavior" here too.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java
##########
@@ -1338,14 +1368,23 @@ private boolean restoreLatestCheckpointedStateInternal(
                        CompletedCheckpoint latest = 
completedCheckpointStore.getLatestCheckpoint(isPreferCheckpointForRecovery);
 
                        if (latest == null) {
+                               LOG.info("No checkpoint found during restore.");
+
                                if (errorIfNoCheckpoint) {
                                        throw new IllegalStateException("No 
completed checkpoint available");
-                               } else {
+                               }
+
+                               if (coordinatorRestoreBehavior == 
CoordinatorRestore.ALWAYS) {

Review comment:
       nit: how about `if (coordinatorRestoreBehavior.resetIfNoState())` ?

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java
##########
@@ -1869,4 +1908,16 @@ public boolean isForce() {
                        return props.forceCheckpoint();
                }
        }
+
+       private enum CoordinatorRestore {
+
+               /** Coordinators are always restored. If there is no 
checkpoint, they are restored empty. */
+               ALWAYS,

Review comment:
       nit: the following set of names would be more clear to me: `SKIP, 
RESTORE_IF_PRESENT, RESTORE_OR_RESET`

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/operators/coordination/OperatorCoordinator.java
##########
@@ -137,7 +145,7 @@ default void notifyCheckpointAborted(long checkpointId) {}
         * complete (for example when a system failure happened directly after 
committing the checkpoint,
         * before calling the {@link #notifyCheckpointComplete(long)} method).
         */
-       void resetToCheckpoint(byte[] checkpointData) throws Exception;
+       void resetToCheckpoint(@Nullable byte[] checkpointData) throws 
Exception;

Review comment:
       nit: I think `@Nullable` is a bit more error-prone and less readable 
than two explicit methods: `reset()` and `resetAndRestore(byte[])`. The latter 
could call the former by default.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to