-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix S3InputStream.readFully connection leak #13899
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
Fix S3InputStream.readFully connection leak #13899
Conversation
| String range = String.format("bytes=%s-%s", position, position + length - 1); | ||
|
|
||
| IOUtil.readFully(readRange(range), buffer, offset, length); | ||
| try (InputStream stream = readRange(range)) { |
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.
readTail method has the same problem no?
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.
Also, it seems that the same pattern is present in ADLS and GCS input streams!
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.
Yes. I was starting small to see if that's the correct approach. I will do the follow up PRs for other places.
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.
Nice find @nandorKollar (bad assumption that readFully would close the stream). I would agree there's the same issue for readTail and the other implementations.
danielcweeks
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.
+1 (pending checks)
When S3InputStreamReadFully is called it does not expose the underlying InputStream to the caller and does not close it on its own. This leads to a connection leak in S3Client since the underlying connection is not returned to connection pool in Apace HTTP client.
c682668 to
894e108
Compare
|
@danielcweeks could you please re-approve the GH actions run? It failed on spotless check on the first attempt. Sorry, my bad. |
nandorKollar
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.
LGTM, though the other cases (readTail and ADLS/GCS) mentioned before also might need attention, maybe in a separate PR?
That's exactly what I mentioned above. I'll do another PR for those. Thanks! |
|
Thanks @AnatolyPopov! |
A follow-up to apache#13899 with more fixes of the same issue.
A follow-up to apache#13899 with more fixes of the same issue.
A follow-up to apache#13899 with more fixes of the same issue.
When S3InputStreamReadFully is called it does not expose the underlying InputStream to the caller and does not close it on its own. This leads to connection leak in S3Client since the underlying connection is not returned to connection pool in Apace HTTP client.