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

Add cancellable context to Fetch requests #31

Merged
merged 2 commits into from
Dec 10, 2020

Conversation

findkim
Copy link
Contributor

@findkim findkim commented Dec 9, 2020

Fetch requests that are Consul blocking queries leak on shutdown and hold onto the TCP connection causing Consul server to also hold until reaped. This can quickly result in reaching Consul client connection limits and causing subsequent client restarts to error due to agent rate limits, 429 and EOFs.

The PR adds a cancellable context to the QueryOptions for the Consul API client to use for HTTP requests. This allows view.Stop() to cancel the context which cancels the in-flight request. Canceling the request releases the underlying TCP connection from active to now possible idle state, which could then be cleaned up when ClientSet.Stop() -> http.Client.CloseIdleConnections() is called.

Fetch requests that are Consul blocking queries leak on shutdown
and hold onto the TCP connection causing Consul server to hold
until reaped. This can quickly result in reaching Consul client
connection limits and causing subsequent client restarts to error
due to agent rate limits, 429 and EOFs.
@findkim findkim added the bug Something isn't working label Dec 9, 2020
view.go Show resolved Hide resolved
view_test.go Show resolved Hide resolved
view.go Show resolved Hide resolved
Copy link
Contributor

@eikenb eikenb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. No changes required (well you know, unless you want to ;).

Copy link
Member

@lornasong lornasong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excited about these changes! i just had a couple questions of things that I wanted to make sure I understood and wanted to learn more about your thinking - no changes necessary.

internal/dependency/dependency.go Outdated Show resolved Hide resolved
internal/dependency/dependency.go Show resolved Hide resolved
view_test.go Outdated Show resolved Hide resolved
@findkim findkim merged commit 36dcd2d into master Dec 10, 2020
@findkim findkim deleted the cancel-blocking-query-reqs branch December 10, 2020 15:36
@findkim
Copy link
Contributor Author

findkim commented Dec 10, 2020

Thanks for the review everyone!

I do want to note that context is currently used for Consul dependencies, but are not piped through to the Vault dependencies yet. I'm not as familiar with those and for timing purposes, I focused on Consul.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants