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

Comments

Projects
None yet
3 participants
@gregdel
Copy link
Contributor

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

@gopherbot

This comment has been minimized.

Copy link

commented Nov 29, 2017

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

@gregdel

This comment has been minimized.

Copy link
Contributor Author

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 }]

@gopherbot gopherbot closed this in 63a4acb Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.