-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[core] Retry if snapshot commit hint failed. #4701
Conversation
@@ -44,4 +44,19 @@ public static FileIOLoader checkAccess(FileIOLoader fileIO, Path path, CatalogCo | |||
io.exists(path); | |||
return fileIO; | |||
} | |||
|
|||
public static void overwriteFileUtf8WithRetry( |
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.
inline this in commitHint
fileIO.overwriteFileUtf8(path, content); | ||
return; | ||
} catch (IOException e) { | ||
if (loopTime == 0) { |
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.
Sleep a random value here?
@@ -883,6 +884,6 @@ public void commitEarliestHint(long snapshotId) throws IOException { | |||
|
|||
private void commitHint(long snapshotId, String fileName, Path dir) throws IOException { | |||
Path hintFile = new Path(dir, fileName); | |||
fileIO.overwriteFileUtf8(hintFile, String.valueOf(snapshotId)); | |||
FileIOUtils.overwriteFileUtf8WithRetry(fileIO, hintFile, String.valueOf(snapshotId), 3); |
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.
Hard code here? Or make it configurable better?
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.
ok
return; | ||
} catch (IOException e) { | ||
try { | ||
Thread.sleep(RANDOM.nextInt(1000) + 500); |
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.
ThreadLocalRandom.current()
Thread.sleep(RANDOM.nextInt(1000) + 500); | ||
} catch (InterruptedException ex) { | ||
// throw root cause | ||
throw new RuntimeException(e); |
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.
Thread.currentThread().interrupt();
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.
+1
Purpose
Maybe over-writer file will fail, so it's better to add some retries.
Tests
API and Format
Documentation