-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-25596: Fix NPE and avoid permanent unreplicated data due to EOF #2987
Conversation
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
4334b6c
to
eb429dc
Compare
🎊 +1 overall
This message was automatically generated. |
LOG.trace("Interrupted while sleeping between WAL reads"); | ||
Thread.currentThread().interrupt(); | ||
} finally { | ||
entryStream.close(); |
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.
See earlier branch-1 review as to why the try blocks have been restructured here. lgtm
(source.isRecovered() || queue.size() > 1) && this.eofAutoRecovery) { | ||
if ((e instanceof EOFException || e.getCause() instanceof EOFException) | ||
&& (source.isRecovered() || queue.size() > 1) | ||
&& this.eofAutoRecovery) { | ||
try { | ||
if (fs.getFileStatus(queue.peek()).getLen() == 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.
There is a potential race here. queue.peek() is called twice, and can return different results. (There's no guarantee that it won't, right?) A local variable should be assigned just before this line and reused, e.g.
Path head = queue.peek();
if (head != null && fs.getFileStatus(head).getLen() == 0) {
LOG.warn("Forcing removal of 0 length log in queue: {}", head);
...
batch.setLastWalPath(head);
...
}
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.
@apurtell if this is the case where fs.getFileStatus(queue.peek()).getLen() == 0
it will give the same result because the top of the queue is not going to be removed from anywhere except this handling of an exception. Let me know if it makes sense.
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.
You can't call peek on a queue twice and be guaranteed the same result. I get what you are saying but please use a local variable as suggested to avoid a code smell. At some future time this could become a real bug.
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.
Yeah, that makes sense, changing it.
5d83d19
to
9991bd9
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@apurtell @xcangCRM This is the porting of #2975 for the master branch.