-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-6209] Clean up connections in ExecutorClassLoader after failing to load classes (master branch PR) #4944
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
Closed
JoshRosen
wants to merge
4
commits into
apache:master
from
JoshRosen:executorclassloader-leak-master-branch
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e2d70a3
Properly clean up after errors in ExecutorClassLoader
JoshRosen 7ee2261
Add a failing regression test
JoshRosen 961c284
Roll back changes that were added to get the regression test to fail
JoshRosen e0e3c25
Wrap try block around getReponseCode; re-enable keep-alive by closing…
JoshRosen 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
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.
I'm not too familiar with this API - but can this connection object ever leak even if the returned input-stream is closed? Or, can an exception occur before returning from this method and the connection leak that way? I'm guessing these aren't possible but just wanted to educate myself as to how these scenarios won't happen =)
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.
Per the HttpURLConnection Javadoc:
This can cause problems in practice: https://scotte.github.io/2015/01/httpurlconnection-socket-leak/.
Actually, that blog post reminds me that I should probably call
getErrorStream
and read that stream in the next error-handling block prior to calling disconnect.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.
On closer inspection, it looks like you need to consume the errorStream if you want the underlying connection to be eligible for re-use, but we may not necessarily care about that here: http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html
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.
How about if an exception throws before we return the input stream? In that case the input stream is not closed but perhaps the connection is still open?
I'm basically asking, should we have a catch block for Throwable in this method after we instantiate the connection to close the connection if we run into an Exception before returning the input stream?
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.
I think that the
connect()
call is unlikely to fail in ways that leak resources, but suppose it wouldn't hurt to add anothertry-catch
block just to be safe. I can do this tomorrow.