TisonKun commented on a change in pull request #9727: [FLINK-14145] Fix 
getLatestCheckpoint(true) returns wrong checkpoint
URL: https://github.com/apache/flink/pull/9727#discussion_r326695695
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CompletedCheckpointStore.java
 ##########
 @@ -55,31 +54,26 @@
         * added.
         */
        default CompletedCheckpoint getLatestCheckpoint(boolean 
isPreferCheckpointForRecovery) throws Exception {
-               if (getAllCheckpoints().isEmpty()) {
+               List<CompletedCheckpoint> allCheckpoints = getAllCheckpoints();
+               if (allCheckpoints.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;
-                                       }
+               CompletedCheckpoint lastCompleted = 
allCheckpoints.get(allCheckpoints.size() - 1);
+
+               if (lastCompleted.getProperties().isSavepoint() && 
isPreferCheckpointForRecovery && allCheckpoints.size() > 1) {
+                       ListIterator<CompletedCheckpoint> listIterator = 
allCheckpoints.listIterator(allCheckpoints.size() - 1);
 
 Review comment:
   @gyfora Yes. My last concern is also about logging. In your version given 
the last completed is a checkpoint we actually log nothing :P

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

Reply via email to