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 2023/01/03 15:40:15 UTC

[GitHub] [flink-table-store] WencongLiu opened a new pull request, #453: [FLINK-30389] Add retry to read hints

WencongLiu opened a new pull request, #453:
URL: https://github.com/apache/flink-table-store/pull/453

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   -->
   
   ## What is the purpose of the change
   
   Add retry to read hints in SnapshotManager
   
   
   ## Brief change log
   
     - *Introduce the retry logic in SnapshotManager*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no )
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (JavaDocs)
   


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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061121029


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -211,16 +214,18 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
         return findByListFiles(Math::min);
     }
 
-    public Long readHint(String fileName) {
+    public Long readHint(String fileName) throws IOException, InterruptedException{
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
-        try {
+        int retryNumber = 0;
+        while (retryNumber++ < READ_HINT_RETRY_NUM) {
             if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+                try {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));
+                } catch (IOException ignored) {
+                }
             }
-        } catch (Exception e) {
-            LOG.info(
-                    "Failed to read hint file " + fileName + ". Falling back to listing files.", e);
+            TimeUnit.MILLISECONDS.sleep(READ_HINT_RETRY_INTERVAL);

Review Comment:
   Catch and ignore the `InterruptedException`



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


[GitHub] [flink-table-store] JingsongLi merged pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi merged PR #453:
URL: https://github.com/apache/flink-table-store/pull/453


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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061163957


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,16 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
-        try {
-            if (path.getFileSystem().exists(path)) {
+        int retryNumber = 0;
+        while (retryNumber++ < READ_HINT_RETRY_NUM) {
+            try {
                 return Long.parseLong(FileUtils.readFileUtf8(path));
+            } catch (IOException ignored) {

Review Comment:
   `Exception` is more safe, after all, read hint is just an optimization



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


[GitHub] [flink-table-store] WencongLiu commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061096124


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   Done.



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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061120757


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   Maybe we can just remove `if (path.getFileSystem().exists(path)) {`, we already have catch the exception for `FileUtils.readFileUtf8(path)`.



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


[GitHub] [flink-table-store] WencongLiu commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061142837


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   Done.



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -211,16 +214,18 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
         return findByListFiles(Math::min);
     }
 
-    public Long readHint(String fileName) {
+    public Long readHint(String fileName) throws IOException, InterruptedException{
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
-        try {
+        int retryNumber = 0;
+        while (retryNumber++ < READ_HINT_RETRY_NUM) {
             if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+                try {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));
+                } catch (IOException ignored) {
+                }
             }
-        } catch (Exception e) {
-            LOG.info(
-                    "Failed to read hint file " + fileName + ". Falling back to listing files.", e);
+            TimeUnit.MILLISECONDS.sleep(READ_HINT_RETRY_INTERVAL);

Review Comment:
   Done.



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


[GitHub] [flink-table-store] WencongLiu commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061165341


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,16 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
-        try {
-            if (path.getFileSystem().exists(path)) {
+        int retryNumber = 0;
+        while (retryNumber++ < READ_HINT_RETRY_NUM) {
+            try {
                 return Long.parseLong(FileUtils.readFileUtf8(path));
+            } catch (IOException ignored) {

Review Comment:
   Done.



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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061109602


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   ```
   int retryNumber = 0;
   while (retryNumber++ < READ_HINT_RETRY_NUM) {
           try {
                return Long.parseLong(FileUtils.readFileUtf8(path));
           } catch (Exception ignored) {
           }
          TimeUnit.MILLISECONDS.sleep(READ_HINT_RETRY_INTERVAL);
   }
   ```



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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061078195


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   We need to catch exception and ignore exception here.



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


[GitHub] [flink-table-store] WencongLiu commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061118884


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   OK. I've added a fix-up commit. Currently only exception of "Long.parseLong(FileUtils.readFileUtf8(path))" is catched, and others are thrown to invoker.



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -44,6 +45,8 @@ public class SnapshotManager {
     private static final String SNAPSHOT_PREFIX = "snapshot-";
     public static final String EARLIEST = "EARLIEST";
     public static final String LATEST = "LATEST";
+    private static final int READ_HINT_RETRY_NUM = 10;
+    private static final int READ_HINT_RETRY_INTERVAL = 200;

Review Comment:
   Done.



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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061109602


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -214,13 +217,22 @@ public Optional<Snapshot> latestSnapshotOfUser(String user) {
     public Long readHint(String fileName) {
         Path snapshotDir = snapshotDirectory();
         Path path = new Path(snapshotDir, fileName);
+        int retryNumber = 0;
         try {
-            if (path.getFileSystem().exists(path)) {
-                return Long.parseLong(FileUtils.readFileUtf8(path));
+            while (retryNumber++ < READ_HINT_RETRY_NUM) {
+                if (path.getFileSystem().exists(path)) {
+                    return Long.parseLong(FileUtils.readFileUtf8(path));

Review Comment:
   ```
   int retryNumber = 0;
   while (retryNumber++ < READ_HINT_RETRY_NUM) {
           try {
                return Long.parseLong(FileUtils.readFileUtf8(path));
           } catch (Exception ignored) {
           }
          TimeUnit.MILLISECONDS.sleep(READ_HINT_RETRY_INTERVAL);
   }
   ```
   
   We should skip inner exception, then we can retry to read.



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


[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #453: [FLINK-30389] Add retry to read hints

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #453:
URL: https://github.com/apache/flink-table-store/pull/453#discussion_r1061110047


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java:
##########
@@ -44,6 +45,8 @@ public class SnapshotManager {
     private static final String SNAPSHOT_PREFIX = "snapshot-";
     public static final String EARLIEST = "EARLIEST";
     public static final String LATEST = "LATEST";
+    private static final int READ_HINT_RETRY_NUM = 10;
+    private static final int READ_HINT_RETRY_INTERVAL = 200;

Review Comment:
   Maybe the better choice is:
   - `READ_HINT_RETRY_NUM` is 3.
   - `READ_HINT_RETRY_INTERVAL` is 1ms.



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