-
Notifications
You must be signed in to change notification settings - Fork 18k
x/net/http2: Transport is leaking streams on broken Body #27208
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
Comments
Thank you filing this issue @euroelessar and welcome to Go! So to help with a prognosis, proper fix for this issue and for posterity, it would be helpful to paste in here a runnable repro because the conditions that you are described are part of the usual x/net/http2.Transport usages. In the meantime I'll page some http2 folks @rs @tombergan @bradfitz |
Thanks, @odeke-em. |
Standalone example: https://gist.github.com/euroelessar/6f4535db11b8bf024d85253cdaa1db1f |
In case of request body write error, the stream is not reset/forgotten. The following patch fixes the issue, though I'm not sure a cancel is the right response to such problem spec-wise: diff --git a/http2/transport.go b/http2/transport.go
index 9d1f2fa..b5c8701 100644
--- a/http2/transport.go
+++ b/http2/transport.go
@@ -1060,7 +1060,12 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf
default:
}
if err != nil {
- return nil, cs.getStartedWrite(), err
+ startedWrite := cs.getStartedWrite()
+ if startedWrite {
+ cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
+ }
+ cc.forgetStreamID(cs.ID)
+ return nil, startedWrite, err
}
bodyWritten = true
if d := cc.responseHeaderTimeout(); d != 0 { |
Change https://golang.org/cl/132715 mentions this issue: |
This issue seems to be the same one behind googleapis/google-cloud-go#1211 and hashicorp/vault#5419. I see this is attached to the Go 1.12 milestone, but the CL hasn't received any feedback. Are there plans to look at this? |
I plan to look at it. Still targeted towards Go 1.12. (but could also be backported to Go 1.11.x) |
Updates golang/go#27208 Change-Id: I5d9a643f33d27d33b24f670c98f5a51aa6000967 GitHub-Last-Rev: 3ac4a57 GitHub-Pull-Request: #18 Reviewed-on: https://go-review.googlesource.com/c/132715 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Approved & submitted into x/net. Needs bundle into std. |
Thanks for the fast response! |
Thank you! |
@gopherbot, please backport to Go 1.11. |
Backport issue(s) opened: #28673 (for 1.11). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/152080 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.3 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?linux, amd64
What did you do?
golang.org/x/net/http2.Transport
POST
request with non-nil BodyRead
callWhat did you expect to see?
Client fails the request and resets the stream.
What did you see instead?
Client fails the request and leaks the stream (on both client and server sides).
The text was updated successfully, but these errors were encountered: