/ go Public
net: cross compiled Go has lengthy timeouts when resolving names if a DNS server is invalid #29142
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
What did you do?
We cross compiled an application on a mac, with GOOS=linux as the target. When run on target systems where there are two DNS resolvers listed in /etc/resolv.conf, but one of them is unreachable, the application takes quite a while to resolve dns (15s?). Changing the DNS resolution mechanism with GO_DEBUG doesn't appear to work, the error occurs with either the go or cgo DNS resolvers selected. As soon as we comment out the DNS server that is unreachable, the app works fine. It does not matter which one of the DNS servers is unreachable (first one listed, or second). The app is slow, and strace shows it connecting to both of them no matter what.
What did you expect to see?
I was expecting Go to use the primary DNS server first, with a 2 second timeout before using the next in the resolver list, returning the response of the first successful server.
What did you see instead?
Timeouts, and slow applications when the app was built on darwin/amd64 for a target of linux/amd64.
This problem goes away if we do a go build directly on linux/amd64 and do not cross-compile (both using CGO_ENABLED=0 and CGO_ENABLED=1). However, if the primary resolver listed is unreachable for this test case, the timeouts take over 10s for DNS resolution, rather than the expected 2s. If the secondary server is unreachable, it is never hit, as the primary resolved the name already, and no timeouts are noticed
The text was updated successfully, but these errors were encountered: