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

x/net/http2: cancel stream context more proactively when closing or resetting stream #68099

Open
dagood opened this issue Jun 21, 2024 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@dagood
Copy link
Contributor

dagood commented Jun 21, 2024

Go version

go version go1.22.4 linux/amd64

Output of go env in your module/workspace:

GOARCH='amd64'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
GOAMD64='v1'
[... trimmed, does not seem relevant]

What did you do?

When the server closes or resets a stream, in some cases my handler is still running. The handler may be performing an expensive operation or using a lot of memory. Canceling the context as soon as possible means the handler can detect that it's no longer doing useful work and stop wasting resources.

What did you see happen?

In some cases, the handler context is not canceled until later than I'd expect. For example, the scheduler might do a lot of work to wrap up http2 state for a stream reset before cancelling the context.

What did you expect to see?

As soon as the server knows that continuing to run the handler won't do any useful work, the context should be cancelled.

I wrote a CL to cancel earlier in a few cases, but I had trouble writing tests for it: https://go-review.googlesource.com/c/net/+/536515. I'm filing this as an issue in case someone more familiar with x/net/http2 wants to work on it. 🙂

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants