globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

Data Race in DialWithInfo #186

Closed ericmillin closed 6 years ago

ericmillin commented 6 years ago

We have an overburdened CI server that is exposing during testing the following race:

==================
WARNING: DATA RACE
Write at 0x00c420571f68 by goroutine 15:
  vendor/github.com/globalsign/mgo.DialWithInfo()
      vendor/github.com/globalsign/mgo/session.go:602 +0x55e

Previous read at 0x00c420571f68 by goroutine 158:
  vendor/github.com/globalsign/mgo.(*mongoCluster).server()
      vendor/github.com/globalsign/mgo/cluster.go:442 +0x83
  vendor/github.com/globalsign/mgo.(*mongoCluster).syncServersIteration.func1.1()
      vendor/github.com/globalsign/mgo/cluster.go:556 +0x1da

Goroutine 15 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:824 +0x564
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1063 +0xa4
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:777 +0x16d
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1061 +0x4e1
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:978 +0x2cd
  main.main()
      _testmain.go:44 +0x22a

Goroutine 158 (running) created at:
  vendor/github.com/globalsign/mgo.(*mongoCluster).syncServersIteration.func1()
      vendor/github.com/globalsign/mgo/cluster.go:529 +0x174
  vendor/github.com/globalsign/mgo.(*mongoCluster).syncServersIteration()
      vendor/github.com/globalsign/mgo/cluster.go:584 +0x490
  vendor/github.com/globalsign/mgo.(*mongoCluster).syncServersLoop()
      vendor/github.com/globalsign/mgo/cluster.go:392 +0x17b

Should be pretty self-explanatory, but let me know if you have any questions.

domodwyer commented 6 years ago

Hi @ericmillin

What commit are you running? Have you seen https://github.com/globalsign/mgo/issues/178 ? Maybe try development - it might already be resolved.

Dom

jerome-laforge commented 6 years ago

Hello @domodwyer , I was not able to reproduce this issue onto development branch with my tests. On the other hand, I was able to reproduce this race onto master branch with my tests.

Jérôme

domodwyer commented 6 years ago

Awesome, thanks for checking @jerome-laforge!

There's a release PR out so this should be in master soon :)

Dom