-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-2648] Retry FileSystem action instead of failed directly. #3887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e682349
need to add configs
d2e9e5e
add hoodie filesystem retry wrapper
b3297f1
ready to test
99a04ae
done
82ec7c1
fix code style
7b6b763
fix code style
b100a20
merge from master
fe0c868
set fs guard config for hoodie flink table
4b75793
merge from master
c36153a
code review
e314a3c
code review
a38cbda
code revoew
8e8d9ba
merge from master
7f7fc4b
code review
8a709ce
merge from master
f4a5276
code review
1f5392a
code review
ae8b009
code review
04f93a2
code review
3dd7f7d
merge from master
1139ead
code review
c83f659
code review
9d1366b
code review
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
hudi-common/src/main/java/org/apache/hudi/common/fs/FileSystemRetryConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hudi.common.fs; | ||
|
|
||
| import org.apache.hudi.common.config.ConfigClassProperty; | ||
| import org.apache.hudi.common.config.ConfigGroups; | ||
| import org.apache.hudi.common.config.ConfigProperty; | ||
| import org.apache.hudi.common.config.HoodieConfig; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileReader; | ||
| import java.io.IOException; | ||
| import java.util.Properties; | ||
|
|
||
| /** | ||
| * The file system retry relevant config options. | ||
| */ | ||
| @ConfigClassProperty(name = "FileSystem Guard Configurations", | ||
| groupName = ConfigGroups.Names.WRITE_CLIENT, | ||
| description = "The filesystem retry related config options, to help deal with runtime exception like list/get/put/delete performance issues.") | ||
| public class FileSystemRetryConfig extends HoodieConfig { | ||
|
|
||
| public static final ConfigProperty<String> FILESYSTEM_RETRY_ENABLE = ConfigProperty | ||
| .key("hoodie.filesystem.operation.retry.enable") | ||
| .defaultValue("false") | ||
| .sinceVersion("0.11.0") | ||
| .withDocumentation("Enabled to handle list/get/delete etc file system performance issue."); | ||
|
|
||
| public static final ConfigProperty<Long> INITIAL_RETRY_INTERVAL_MS = ConfigProperty | ||
| .key("hoodie.filesystem.operation.retry.initial_interval_ms") | ||
| .defaultValue(100L) | ||
| .sinceVersion("0.11.0") | ||
| .withDocumentation("Amount of time (in ms) to wait, before retry to do operations on storage."); | ||
|
|
||
| public static final ConfigProperty<Long> MAX_RETRY_INTERVAL_MS = ConfigProperty | ||
| .key("hoodie.filesystem.operation.retry.max_interval_ms") | ||
| .defaultValue(2000L) | ||
| .sinceVersion("0.11.0") | ||
| .withDocumentation("Maximum amount of time (in ms), to wait for next retry."); | ||
|
|
||
| public static final ConfigProperty<Integer> MAX_RETRY_NUMBERS = ConfigProperty | ||
| .key("hoodie.filesystem.operation.retry.max_numbers") | ||
| .defaultValue(4) | ||
| .sinceVersion("0.11.0") | ||
| .withDocumentation("Maximum number of retry actions to perform, with exponential backoff."); | ||
|
|
||
| public static final ConfigProperty<String> RETRY_EXCEPTIONS = ConfigProperty | ||
| .key("hoodie.filesystem.operation.retry.exceptions") | ||
| .defaultValue("") | ||
| .sinceVersion("0.11.0") | ||
| .withDocumentation("The class name of the Exception that needs to be re-tryed, separated by commas. " | ||
| + "Default is empty which means retry all the IOException and RuntimeException from FileSystem"); | ||
|
|
||
| private FileSystemRetryConfig() { | ||
| super(); | ||
| } | ||
|
|
||
| public long getInitialRetryIntervalMs() { | ||
| return getLong(INITIAL_RETRY_INTERVAL_MS); | ||
| } | ||
|
|
||
| public long getMaxRetryIntervalMs() { | ||
| return getLong(MAX_RETRY_INTERVAL_MS); | ||
| } | ||
|
|
||
| public int getMaxRetryNumbers() { | ||
| return getInt(MAX_RETRY_NUMBERS); | ||
| } | ||
|
|
||
| public boolean isFileSystemActionRetryEnable() { | ||
| return Boolean.parseBoolean(getStringOrDefault(FILESYSTEM_RETRY_ENABLE)); | ||
| } | ||
|
|
||
| public static FileSystemRetryConfig.Builder newBuilder() { | ||
| return new Builder(); | ||
| } | ||
|
|
||
| public String getRetryExceptions() { | ||
| return getString(RETRY_EXCEPTIONS); | ||
| } | ||
|
|
||
| /** | ||
| * The builder used to build filesystem configurations. | ||
| */ | ||
| public static class Builder { | ||
|
|
||
| private final FileSystemRetryConfig fileSystemRetryConfig = new FileSystemRetryConfig(); | ||
|
|
||
| public Builder fromFile(File propertiesFile) throws IOException { | ||
| try (FileReader reader = new FileReader(propertiesFile)) { | ||
| fileSystemRetryConfig.getProps().load(reader); | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| public Builder fromProperties(Properties props) { | ||
| this.fileSystemRetryConfig.getProps().putAll(props); | ||
| return this; | ||
| } | ||
|
|
||
| public Builder withMaxRetryNumbers(int numbers) { | ||
| fileSystemRetryConfig.setValue(MAX_RETRY_NUMBERS, String.valueOf(numbers)); | ||
| return this; | ||
| } | ||
|
|
||
| public Builder withInitialRetryIntervalMs(long intervalMs) { | ||
| fileSystemRetryConfig.setValue(INITIAL_RETRY_INTERVAL_MS, String.valueOf(intervalMs)); | ||
| return this; | ||
| } | ||
|
|
||
| public Builder withMaxRetryIntervalMs(long intervalMs) { | ||
| fileSystemRetryConfig.setValue(MAX_RETRY_INTERVAL_MS, String.valueOf(intervalMs)); | ||
| return this; | ||
| } | ||
|
|
||
| public Builder withFileSystemActionRetryEnabled(boolean enabled) { | ||
| fileSystemRetryConfig.setValue(FILESYSTEM_RETRY_ENABLE, String.valueOf(enabled)); | ||
| return this; | ||
| } | ||
|
|
||
| public FileSystemRetryConfig build() { | ||
| fileSystemRetryConfig.setDefaults(FileSystemRetryConfig.class.getName()); | ||
| return fileSystemRetryConfig; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be we can name this as "hoodie.filesystem.operation.retry.max.count"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_times seems better ?