Skip to content
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: Using multiple resolvers shows unexpected results while used concurrently #22908

Closed
gregdel opened this issue Nov 28, 2017 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@gregdel
Copy link
Contributor

gregdel commented Nov 28, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

greg@lois:~ ❯ go env
GOARCH="amd64"
GOBIN="/home/greg/dev/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/greg/dev/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build769697684=/tmp/go-build -gno-
record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

I'm trying to use custom resolvers to resolve the same host using concurrent goroutines. The current pure go resolver uses a global lookupGroup which merges LookupIPAddr calls together for lookups for the same host. As a result only one of the resolvers is used to permform the dns lookup but the result is shared by all the resolvers.

Example code: http://play.golang.org/p/eyR2mhBs1C

What did you expect to see?

I'm expecting each resolver to dial for its own lookups

What did you see instead?

This is the output of the example script:

Creating resolver 0
Creating resolver 1
dial using the resolver 1
dial using the resolver 1
result from 0: [{216.58.198.206 } {2a00:1450:4007:816::200e }]
result from 1: [{216.58.198.206 } {2a00:1450:4007:816::200e }]

Proposal

Maybe the lookupGroup should be local the resolver so that each resolver is really independent.

@bradfitz bradfitz added this to the Go1.11 milestone Nov 28, 2017
@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 28, 2017
@gopherbot
Copy link

Change https://golang.org/cl/80775 mentions this issue: net: Make pure-go custom resolvers independent

@gregdel
Copy link
Contributor Author

gregdel commented Nov 29, 2017

Output with the go binary built from my PR:

Creating resolver 0
Creating resolver 1
dial using the resolver 1
dial using the resolver 0
dial using the resolver 1
dial using the resolver 0
result from 1: [{216.58.206.238 } {2a00:1450:4007:80a::200e }]
result from 0: [{216.58.206.238 } {2a00:1450:4007:80a::200e }]

@golang golang locked and limited conversation to collaborators Jun 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants