You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/02 08:29:55 UTC

[GitHub] [flink] pnowojski commented on a diff in pull request #21440: [FLINK-28766][tests] Safe iterate over checkpoint files in order to avoid exception during parallel savepoint deletion

pnowojski commented on code in PR #21440:
URL: https://github.com/apache/flink/pull/21440#discussion_r1037895413


##########
flink-tests/src/test/java/org/apache/flink/test/checkpointing/UnalignedCheckpointStressITCase.java:
##########
@@ -559,4 +551,30 @@ public Record map(Record value) throws Exception {
             return value.validate();
         }
     }
+
+    /**
+     * The file visitor which is looking for the most recent checkpoint.
+     */
+    private static class MaxCheckpointFileVisitor extends SimpleFileVisitor<Path> {
+        private Path maxCheckpointDir;
+
+        @Override
+        public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) {
+            if (path.endsWith("_metadata")) {
+                int curCheckpointId = getCheckpointNumberFromPath(path.getParent());
+                int prevCheckpointId =
+                        maxCheckpointDir == null
+                                ? -1
+                                : getCheckpointNumberFromPath(maxCheckpointDir);
+                if (prevCheckpointId < curCheckpointId) {
+                    maxCheckpointDir = path.getParent();
+                }
+            }
+            return FileVisitResult.CONTINUE;
+        }
+
+        public Path getMaxCheckpointDir() {
+            return maxCheckpointDir;
+        }
+    }

Review Comment:
   This answer: https://stackoverflow.com/a/72865899/8149051
   
   suggests that this might be not enough? 🤔 However I remember using the visitor exactly the way you were using to solve the same problem, so I'm not sure if the answer is correct.



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

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org