Closed vrecan closed 6 years ago
Is this a known issue, seems odd that no one cares about a data race?
Which version are you using?
What is google.golang.org/grpc/clientconn.go:505
showing in your vendered gRPC?
In the current master branch, https://github.com/grpc/grpc-go/blob/master/clientconn.go#L505 is a }
.
Encountered same issue with 1.3.0 when using a logger that discards output. When I disabled tracing, it worked just fine.
WARNING: DATA RACE
Write at 0x000004b6c4d0 by goroutine 87:
github.com/user/repo/pkg/lb.TestWorker()
/Users/V/Go/src/github.com/user/repo/pkg/lb/worker_test.go:36 +0x6b
testing.tRunner()
/usr/local/Cellar/go/1.8.1/libexec/src/testing/testing.go:657 +0x107
Previous read at 0x000004b6c4d0 by goroutine 83:
github.com/user/repo/vendor/google.golang.org/grpc/grpclog.Printf()
/Users/V/Go/src/github.com/user/repo/vendor/google.golang.org/grpc/grpclog/logger.go:87 +0x3e
github.com/user/repo/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn.func1()
/Users/V/Go/src/github.com/user/repo/vendor/google.golang.org/grpc/clientconn.go:613 +0x159
Goroutine 87 (running) created at:
testing.(*T).Run()
/usr/local/Cellar/go/1.8.1/libexec/src/testing/testing.go:697 +0x543
testing.runTests.func1()
/usr/local/Cellar/go/1.8.1/libexec/src/testing/testing.go:882 +0xaa
testing.tRunner()
/usr/local/Cellar/go/1.8.1/libexec/src/testing/testing.go:657 +0x107
testing.runTests()
/usr/local/Cellar/go/1.8.1/libexec/src/testing/testing.go:888 +0x4e0
testing.(*M).Run()
/usr/local/Cellar/go/1.8.1/libexec/src/testing/testing.go:822 +0x1c3
main.main()
github.com/user/repo/pkg/lb/_test/_testmain.go:48 +0x20f
Goroutine 83 (finished) created at:
github.com/user/repo/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn()
/Users/V/Go/src/github.com/user/repo/vendor/google.golang.org/grpc/clientconn.go:621 +0xae3
github.com/user/repo/vendor/google.golang.org/grpc.DialContext.func3()
/Users/V/Go/src/github.com/user/repo/vendor/google.golang.org/grpc/clientconn.go:403 +0x20c
Ok nevermind. In my case, disabling tracing didn't to a thing. It seems like a separate issue caused by setting grpc logger when -race is tested (set by grpclog.SetLogger(log.New(ioutil.Discard, "", 0))
)
UPDATED: confirmed it as unrelated and pretty much issue with my own code. Setting grpclog logger once per package in TestMain fixed it. Disregard previous comment.
@23doors Thanks for the update. @vrecan To pursue this bug we'll need more information from your side. Please respond to Menghan's comment, when you can. However, if this is not an issue anymore feel free to close it.
I get a data race when I set EnableTracing in my unit tests. I can't fix it easily because the goroutine reading the value exists in GRPC itself. This seems like something that should be a function that is mutex protected. For now I am going to work around it by hard coding it to false but I would really like to be able to use this without a potential race.