You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2023/01/04 08:31:57 UTC
[flink-table-store] branch master updated: [FLINK-30389] Add retry to read hints
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-table-store.git
The following commit(s) were added to refs/heads/master by this push:
new 2586516e [FLINK-30389] Add retry to read hints
2586516e is described below
commit 2586516e12c9c4141e80741fb604e65c4d9c7445
Author: WencongLiu <10...@users.noreply.github.com>
AuthorDate: Wed Jan 4 16:31:51 2023 +0800
[FLINK-30389] Add retry to read hints
This closes #453
---
.../flink/table/store/file/utils/SnapshotManager.java | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java
index a7004afe..9b0f9ef3 100644
--- a/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java
+++ b/flink-table-store-core/src/main/java/org/apache/flink/table/store/file/utils/SnapshotManager.java
@@ -32,6 +32,7 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.Optional;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.function.BinaryOperator;
import static org.apache.flink.table.store.file.utils.FileUtils.listVersionedFiles;
@@ -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 = 3;
+ private static final int READ_HINT_RETRY_INTERVAL = 1;
private final Path tablePath;
@@ -214,13 +217,16 @@ public class SnapshotManager {
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 (Exception ignored) {
+ }
+ try {
+ TimeUnit.MILLISECONDS.sleep(READ_HINT_RETRY_INTERVAL);
+ } catch (InterruptedException ignored) {
}
- } catch (Exception e) {
- LOG.info(
- "Failed to read hint file " + fileName + ". Falling back to listing files.", e);
}
return null;
}