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: LookupHost("localhost") returning "no such host" error #3575
Comments
After searching around, it seems that getaddrinfo may not be thread-safe on OSX. Although, I'm not sure how credible this is. http://stackoverflow.com/questions/1212716/python-interpreter-blocks-multithreaded-dns-requests |
Labels changed: added priority-later, removed priority-triage. Owner changed to @rsc. Status changed to Accepted. |
After some more research, I believe this is essentially the same issue: https://golang.org/issue/1724 |
I'm able to reproduce a similar problem on Linux. If I do lots of concurrent GET requests to http://www.google.com, I start getting DNS errors. See the attached program. When I run this program, about half of the 300 requests fail with this error: Get http://www.google.com: lookup www.google.com: no such host Attachments:
|
Or to cut HTTP out of the equation, here's a version that just does the DNS lookups. Attachments:
|
I think this may be related to file descriptor exhaustion in your process, which causes DNS lookups to fail. For example, your version that uses http.Get never closes the response body, leaking a fd. Can you please try the following. 1. make sure you close the response body 2. rebuild your tree with the env var CGO_ENABLED=0 set, this will disable the integration with your OSs native dns resolver, and use the pure go version instead. |
Comment 10 by jason@squarepenguin.com: I have the same problem (DNS lookups failing) running 1.0.2 on Debian 6 if I run more than 7-8 concurrent requests. |
A couple more observations: - If I put a lock around only the getaddrinfo call in net.cgoLookupIPCNAME, things work as expected. (Again, not suggesting this as a solution.) - I wrote a C program that exhibits the same behavior, so this may not be a Go problem after all. Source code is attached for the curious. (Compile with gcc -lpthread dnserror.c.) So now I'm left with the unfortunate possibilities of a glibc bug or some kind of configuration error. I've come across a few other people with this problem also, so if it's a configuration error it must be a relatively common one. Attachments:
|
Your c program compiles and runs fine on ubuntu 12.04 amd64. I wonder if this is problem only affects the 32bit systems? Could those commenting on this ticket please ensure they include details about their host os, arch and revision. @edsrzf, are you able to test this on another host, or better yet on another network, to rule out a problematic DNS resolver. I hear 8.8.8.8 is a good resolver. |
Comment 13 by jason@squarepenguin.com: No problems either on debian 6 amd64 running dnserror.c. |
The machine I've been using thus far is running Arch Linux amd64 with glibc 2.16. If I change my name server to 8.8.8.8, it significantly reduces the number of errors I get from dnserror.c: from 150-160 down to 8-24. It makes dnserror.go run flawlessly. If I try on my laptop, which runs Ubuntu 11.10 amd64 with eglibc 2.13, I have no problems with any program/name server combination. This is on the same network. |
Comment 21 by shane@stealnetwork.com: Verified on OSX 10.8.4. The exhaustion seems to be FD related to kqueue. Both the go program and a simple python program. lsof indicates about 250 open KQUEUE file handles. Attachments:
|
Comment 24 by robin@us2.nl: I can also confirm that I have this problem on multiple environments (latest OSX, CentOS 6, CentOS 5 and Ubuntu 13.10). All 64 bit machines. |
My go code kicks off 16 goroutines to concurrently run sql on postgresql databases that are on hosts n01..n16 on my local network. Once in a while (but not always) I get errors such as these: dbh.Prepare():dial tcp: lookup n02: no such host dbh.Prepare():dial tcp: lookup n05: no such host Usually when this occurs only 2 to 3 hosts are not found, while the rest are found. When I do another run of the program immediately after getting such errors, then the errors dissappear. Also if I replace the hostnames by ip-addresses in the database connection parameter string, then the errors do not occur. System: debian linux running kernel 3.2.0-4-amd64 Go version go1.2 linux/amd64 |
You may want to check issue #6336. |
fiorix, what version of glibc do you have? It's likely you don't have their fix yet. I think this was determined to not be a Go bug (see issue #6336). We might detect and work around it, though. Alternatively, you can update your glibc, or use the netgo build tag and use Go's built-in DNS resolver instead of the system one. |
It's Ubuntu 14.04 with the latest libc 2.19. I've been following issue #6336 as well. Tried the netgo build tag (go install -a -tags netgo std and netgo net iirc) but dns resolution eventually stops working after a while. Perhaps because my program uses sqlite thus cgo can't be disabled? Not sure if that has anything to do with it. |
Sorry for the double post but this one includes more details. How do I do a lock around net.cgoLookupIPCNAME? When I try the workaround as suggested in #32 I get: "go install runtime: open /usr/local/go/pkg/linux_amd64/runtime.a: permission denied". If I sudo then it seems to work but then when I try to install other packages I get: "go install container/list: open /usr/local/go/pkg/linux_amd64/container/list.a: permission denied go install unicode/utf8: open /usr/local/go/pkg/linux_amd64/unicode/utf8.a: permission denied go install crypto/subtle: open /usr/local/go/pkg/linux_amd64/crypto/subtle.a: permission denied go install hash: open /usr/local/go/pkg/linux_amd64/hash.a: permission denied go install unicode: open /usr/local/go/pkg/linux_amd64/unicode.a: permission denied". I then uninstalled then reinstalled Go. Am I doing something wrong here? Using Linux Mint 17. |
I close this issue for the following reasons.
In addition, go1.4 has a test case that is able to invoke simultaneous query-response exchanges.
Please try it for troubleshooting, when you have a question with regard to DNS behavior within dial, lookup APIs. |
@mikioh I think this is still happening..
|
Hm, |
Please open a new issue with https://github.com/golang/go/blob/master/CONTRIBUTING.md. |
Attachments:
The text was updated successfully, but these errors were encountered: