-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/httputil: request may be killed by mistake by former cancel request in ReverseProxy.ServeHTTP #16041
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
CC @adg |
Are you able to write a test that demonstrates the issue? I have a couple of ideas what might be wrong, but without a test I can't be sure. |
If it helps at all I did spend some time looking at this and trying to reproduce with various means, such as adding delay between the clientGone close being noticed and CancelRequest being called. And I tried with both 1.6.2 and tip post-1.7beta2. Wasn't able to come up with anything but happy to test further if there are any hunches. Any more info on requests (specifically ones like "Request A") would be useful, such as what HTTP method they used, whether they had a body, etc. |
I don't think step 8 in your scenario ( In any case, more details as requested by @adg and @dpiddy would be nice. How can we reproduce this? What do the requests look like? How are the 10% of requests being canceled? I'd like to help if I can see it fail. Thanks. For now, kicking to Go 1.8, unless you can get back to us soon. |
Closing due to timeout. Let us know and reopen if you have more details. |
Hi:
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
What did you see instead?
Finally I find this:
There is a goroutine here(in ServeHTTP): goroutine
this goroutine is used for receiving
clientGone
orreqDone
signal, however, we assume this scene:ServeHTTP
start handlingRequest A
(using underlyingnet.Conn C
)Request A
was canceled by its client (sending sig toclientGone
)use of closed network connection
in go1.6- or other error in go1.6+)ServeHTTP
start to return and defer close(reqDone) is executed(close is non-block, soServeHTTP
may be return before thegoroutine A
receive close signal, butgoroutine A
is still alive)net/http
putnet.Conn C
to IdleConnRequest B
arrived andnet/http
pick the same underlyingnet.Conn C
ServeHTTP
start handlingRequest B
(using the same underlyingnet.Conn C
)goroutine A
got signalclientGone
first, and then doCancelRequest
which will closenet.Conn C
Request B
's RoundTrip return error cause its underlying conn is closedThe text was updated successfully, but these errors were encountered: