-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[FLINK-30389] Add retry to read hints #453
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
Conversation
| return Long.parseLong(FileUtils.readFileUtf8(path)); | ||
| while (retryNumber++ < READ_HINT_RETRY_NUM) { | ||
| if (path.getFileSystem().exists(path)) { | ||
| return Long.parseLong(FileUtils.readFileUtf8(path)); |
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.
We need to catch exception and ignore exception here.
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.
Done.
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.
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.
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. I've added a fix-up commit. Currently only exception of "Long.parseLong(FileUtils.readFileUtf8(path))" is catched, and others are thrown to invoker.
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.
Maybe we can just remove if (path.getFileSystem().exists(path)) {, we already have catch the exception for FileUtils.readFileUtf8(path).
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.
Done.
| 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; |
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.
Maybe the better choice is:
READ_HINT_RETRY_NUMis 3.READ_HINT_RETRY_INTERVALis 1ms.
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.
Done.
| } catch (Exception e) { | ||
| LOG.info( | ||
| "Failed to read hint file " + fileName + ". Falling back to listing files.", e); | ||
| TimeUnit.MILLISECONDS.sleep(READ_HINT_RETRY_INTERVAL); |
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.
Catch and ignore the InterruptedException
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.
Done.
| while (retryNumber++ < READ_HINT_RETRY_NUM) { | ||
| try { | ||
| return Long.parseLong(FileUtils.readFileUtf8(path)); | ||
| } catch (IOException ignored) { |
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.
Exception is more safe, after all, read hint is just an optimization
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.
Done.
JingsongLi
left a comment
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.
Hi @WencongLiu thanks for the update, just one comment.
JingsongLi
left a comment
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.
Looks good to me! Thanks @WencongLiu
What is the purpose of the change
Add retry to read hints in SnapshotManager
Brief change log
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation