yanghua commented on a change in pull request #8410: [FLINK-11159] Allow configuration whether to fall back to savepoints for restore URL: https://github.com/apache/flink/pull/8410#discussion_r283316804
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/StandaloneCompletedCheckpointStore.java ########## @@ -77,8 +79,32 @@ public void addCheckpoint(CompletedCheckpoint checkpoint) throws Exception { } @Override - public CompletedCheckpoint getLatestCheckpoint() { - return checkpoints.isEmpty() ? null : checkpoints.getLast(); + public CompletedCheckpoint getLatestCheckpoint(boolean isPreferCheckpointForRecovery) { + if (checkpoints.isEmpty()) { + return null; + } + + CompletedCheckpoint candidate = checkpoints.getLast(); Review comment: I will give a default implementation in the `CompletedCheckpointStore `: ```java default CompletedCheckpoint getLatestCheckpoint(boolean isPreferCheckpointForRecovery) throws Exception { if (getAllCheckpoints().isEmpty()) { return null; } CompletedCheckpoint candidate = getAllCheckpoints().get(getAllCheckpoints().size() - 1); if (isPreferCheckpointForRecovery && getAllCheckpoints().size() > 1) { List<CompletedCheckpoint> allCheckpoints; try { allCheckpoints = getAllCheckpoints(); ListIterator<CompletedCheckpoint> listIterator = allCheckpoints.listIterator(allCheckpoints.size() - 1); while (listIterator.hasPrevious()) { CompletedCheckpoint prev = listIterator.previous(); if (!prev.getProperties().isSavepoint()) { candidate = prev; LOG.info("Found a completed checkpoint before the latest savepoint, will use it to recover!"); break; } } } catch (Exception e) { LOG.error("Method getAllCheckpoints caused exception : ", e); throw new FlinkRuntimeException(e); } } return candidate; } ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services