-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net/http: background read can lose a byte #18535
Comments
I just tried on tip |
It's not a problem in the testing package. The net/http Server is seeing a bad request and closing the connection. You have a bunch of different goroutines, running in parallel, writing to the same network connection. As the socket buffer fills up, nothing guarantees that those writes are atomic. When I run an strace, I see that eventually a short write occurs. The Go code calls write again with the remaining bytes, but in the meantime another thread does a write to the same socket. The HTTP server sees a mangled request, returns a "400 Bad Request" error, and closes the connection. The next write fails with a broken pipe, and your code panics. I don't think there is anything we can fix here, so closing. |
Wow. My bad. Thank you.
…On Fri, Jan 6, 2017 at 7:05 AM Ian Lance Taylor ***@***.***> wrote:
Closed #18535 <#18535>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#18535 (comment)>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAAALr-s10JPXw5X2a2kY6WJgxGFSkhAks5rPlgZgaJpZM4Lcg43>
.
|
I've modified the code to not share a connection but rather each running goroutine gets their own. I'm still seeing the issue and have dug around in dtruss looking for clues but I don't see any malformed requests expect when I copy the responses to stderr I do see a 400 response after many valid responses. I may be doing something very silly again but I can't seem to find it. Any help is appreciated. Update bench:
|
CC @bradfitz This is a real bug. The net/http server is dropping an occasional byte. If I add these lines to
your program triggers the panic. Doing a background read when we already have a byte from an earlier background read is causing one of the bytes to be lost. I don't understand exactly what triggers the condition. It has something to do with a full TCP buffer containing many GET requests and ending in the middle of a line. I hope that Brad can take it from here. |
I guess I now have weekend plans. |
Your weekend is open again: https://golang.org/cl/34920. |
CL https://golang.org/cl/34920 mentions this issue. |
Killer. Thank you @ianlancetaylor. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +41908a5 Thu Dec 1 02:54:21 2016 +0000 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
I ran this benchmark:
What did you expect to see?
PASS
What did you see instead?
The text was updated successfully, but these errors were encountered: