1u0 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_r326561727
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CompletedCheckpointStore.java
##########
@@ -60,6 +60,10 @@ default CompletedCheckpoint getLatestCheckpoint(boolean
isPreferCheckpointForRec
}
CompletedCheckpoint candidate =
getAllCheckpoints().get(getAllCheckpoints().size() - 1);
+ if (!candidate.getProperties().isSavepoint()) {
+ return candidate;
+ }
Review comment:
~~This `if` check can be moved into the next `if` block. This would be more
explicit that this check is specific only for `isPreferCheckpointForRecovery =
true` and has no effect otherwise.~~
Additional suggestion: although it's not relevant to your PR and the changes
in the ticket, you can assign a variable for `getAllCheckpoints()` once in the
top of the method. This would avoid additional method calls, array copies and
should make this method more clearer.
**Update:** you can remove the new `if` block and change the line with
`allCheckpoints.listIterator(allCheckpoints.size() - 1);` to
`allCheckpoints.listIterator(allCheckpoints.size());`. This will start
iteration from the very last element and would basically achieve the same goal
that you've introduced with the new `if` block.
----------------------------------------------------------------
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]
With regards,
Apache Git Services