Skip to content
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

Ensure https proxy connections don't clog up the ConnectionPool #580

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Sep 16, 2020

Fixes #562. Despite lots of back and forth on this issue, it turns out
there's a simpler diagnosis & fix that worrying too much about when
sockets will throw when closeing (which we should certainly get all
cleaned up one day).

The real issue here is in ConnectionPool.sslupgrade which was
effectively swapping our Connection that we formally "acquired" from
the connection pool with a new one that had a https-ssl-upgraded
SSLContext to do the request tunneling. The issue with just swapping
the Connection is that the original connection was never properly
"released" to the connection pool, so connections were acquired, but
never released, and eventually we hit the connection_limit. The
proposed solution here (which works locally to avoid getting hung up on
the connection pool clogging), is to introduce a new
kill!(c::Connection) method that "releases" a connection without
returning it to the connection pool. So we signal to the pool that a
connection has finished, but it's not put back in the queue to be
re-used, which is what we want. I should note that this does mean that
proxied https requests then don't really respect the connection_limit,
but also note that it never has due to this "swapping".

Fixes #562. Despite lots of back and forth on this issue, it turns out
there's a simpler diagnosis & fix that worrying too much about when
sockets will throw when `close`ing (which we should certainly get all
cleaned up one day).

The _real_ issue here is in `ConnectionPool.sslupgrade` which was
effectively swapping our `Connection` that we formally "acquired" from
the connection pool with a new one that had a https-ssl-upgraded
`SSLContext` to do the request tunneling. The issue with just swapping
the `Connection` is that the original connection was never properly
"released" to the connection pool, so connections were acquired, but
never released, and eventually we hit the `connection_limit`. The
proposed solution here (which works locally to avoid getting hung up on
the connection pool clogging), is to introduce a new
`kill!(c::Connection)` method that "releases" a connection without
returning it to the connection pool. So we signal to the pool that a
connection has finished, but it's not put back in the queue to be
re-used, which is what we want. I should note that this does mean that
proxied https requests then don't really respect the `connection_limit`,
but also note that it never has due to this "swapping".
@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2020

Codecov Report

Merging #580 into master will increase coverage by 1.66%.
The diff coverage is 11.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #580      +/-   ##
==========================================
+ Coverage   75.94%   77.60%   +1.66%     
==========================================
  Files          37       37              
  Lines        2257     2434     +177     
==========================================
+ Hits         1714     1889     +175     
- Misses        543      545       +2     
Impacted Files Coverage Δ
src/ConnectionPool.jl 76.31% <0.00%> (+2.14%) ⬆️
src/ConnectionRequest.jl 52.63% <25.00%> (+6.33%) ⬆️
src/AWS4AuthRequest.jl 79.36% <0.00%> (-0.30%) ⬇️
src/Messages.jl 92.48% <0.00%> (-0.02%) ⬇️
src/HTTP.jl 100.00% <0.00%> (ø)
src/ascii.jl 100.00% <0.00%> (ø)
src/layers.jl 100.00% <0.00%> (ø)
src/Strings.jl 100.00% <0.00%> (ø)
src/parseutils.jl 100.00% <0.00%> (ø)
src/MessageRequest.jl 100.00% <0.00%> (ø)
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d59510...d2ffc1a. Read the comment docs.

@quinnj quinnj merged commit b127f4d into master Sep 16, 2020
@quinnj quinnj deleted the jq/proxyclose2 branch September 16, 2020 06:37
@vdayanand
Copy link
Contributor

vdayanand commented Sep 16, 2020

Thanks a lot for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTPS request gets blocked while using proxy
3 participants