-
Notifications
You must be signed in to change notification settings - Fork 18k
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: Listen("127.0.0.1:0") errors "address already in use" #16691
Comments
I see identical behavior for net.Listen("tcp", "127.0.0.1:0") in Go 1.6 and Go 1.7. In both cases, I can open around 28,000 before the kernel gets angry at me: package main
import (
"log"
"net"
)
func main() {
var lns []net.Listener
for i := 0; i < 1e9; i++ {
ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
log.Fatalf("%d: %v", i, err)
}
log.Printf("%v: %v", i, ln.Addr().String())
lns = append(lns, ln)
}
} Both say:
Given that you see this in a stress test, I imagine you're forgetting to close something somewhere and just running out of ports in the kernel. I suspect the difference you see between Go 1.6 and Go 1.7 is related to GC/liveness/finalizers and you were getting luckier before in Go 1.6 with something closing listeners more aggressively for you. I'm not sure we can help more until we know more. Ping this bug if you discover something more specific? |
I've checked and we're definitely always closing our listeners in those tests. |
could you try using lsof on the process when it encounter such
error? Also run netstat -ant (or ss -t) to show the used port
numbers at that time.
|
OK, I added
Interestingly I'm able to reproduce this on Go 1.6 now as well. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Ran
github.com/cockroachdb/cockroach/gossip
's tests understress
. I haven't yet attempted to reduce the failure case.What did you expect to see?
Success.
What did you see instead?
Since upgrading to Go 1.7 (rc3,rc4,rc5) we have been seeing the titled failures. See stress: failed test in cockroach/gossip/gossip.test: TestGossipNoForwardSelf cockroachdb/cockroach#8500 and its past incarnations: https://github.com/cockroachdb/cockroach/issues?utf8=%E2%9C%93&q=%22listen%20tcp%20127.0.0.1%3A0%3A%20listen%3A%20address%20already%20in%20use%22
The text was updated successfully, but these errors were encountered: