-
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-25507 Leak of ESTABLISHED sockets when compaction encountered "… #2882
Conversation
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
0421634
to
ef456ab
Compare
sfs.close(); | ||
} | ||
} else { | ||
Closeables.close(scanner, true); |
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.
First, nice debugging. Good find.
Looking at this, I wonder if other InternalScanners can fail in similar way and leak? I see the InternalScanner is implemented in a few places... in KVHeap, and RegionScanner. Could these have the same problem?
Would it be more clean if the createFileScanners were inside a try/finally? Or will scanners act strangely if closed twice... once by internalscanner on the happy path, and then again in the outer finally?
Otherwise, nice work. Above are nits.... just stuff to consider.
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.
Thanks, @saintstack . I check the codes of KVHeap and RegionScanner, they seem OK. Thanks your suggests, I also think createFileScanners should be inside the try/finally. If we only close the scanners when InnerScanner is null, may be we can avoid to close the scanners twice. What do you think?
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.
Sounds good to me @sunhelly . Does that mean update to the PR? Thanks.
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, @saintstack , the PR has been updated.
Function createFileScanners
closes the store file scanners it created when encounters any exception, so it is out the try/finally. When the InternalScanner which contains all the store file scanners is not null, all the scanners will be processed when it closes. So I added a check for InternalScanner if it is null, if so, close the store file scanners manually in finally.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…java.io.IOException: Invalid HFile block magic"
getScannersForCompaction close scanners when it encounters exception, so let createFileScanners outside the try/finally. |
// and then scanner will be null, but scanners for all the hfiles should be closed, | ||
// or else we will find leak of ESTABLISHED sockets. | ||
if (scanner == null) { | ||
for (StoreFileScanner sfs : scanners) { |
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.
this is nice find.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…java.io.IOException: Invalid HFile block magic" (#2882) Signed-off-by: Ramkrishna <ramkrishna@apache.org> Signed-off-by: stack <stack@apache.org>
…java.io.IOException: Invalid HFile block magic" (#2882) Signed-off-by: Ramkrishna <ramkrishna@apache.org> Signed-off-by: stack <stack@apache.org>
…java.io.IOException: Invalid HFile block magic" (#2882) Signed-off-by: Ramkrishna <ramkrishna@apache.org> Signed-off-by: stack <stack@apache.org>
…java.io.IOException: Invalid HFile block magic" (apache#2882) Signed-off-by: Ramkrishna <ramkrishna@apache.org> Signed-off-by: stack <stack@apache.org>
…java.io.IOException: Invalid HFile block magic" (apache#2882) Signed-off-by: Ramkrishna <ramkrishna@apache.org> Signed-off-by: stack <stack@apache.org>
…java.io.IOException: Invalid HFile block magic"