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_r327022580
##########
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:
If you want to log situations when another (non last element) is picked, you
could have added additional check by reference that the picked element is not
the last one.
If you are going to keep your version, could you please move
`lastCompleted.getProperties().isSavepoint()` after
`isPreferCheckpointForRecovery`, so it's not evaluated eagerly.
----------------------------------------------------------------
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