docker / libkv

Distributed key/value store abstraction library
Apache License 2.0
854 stars 205 forks source link

possible data race in AddStore() #206

Open kmulvey opened 5 years ago

kmulvey commented 5 years ago

Im getting a race when running two tests in parallel that both create clients. Shouldn't there be a lock around that initializers map?

==================
WARNING: DATA RACE
Write at 0x00c00008b198 by goroutine 7:
  github.com/kmulvey/scratch/election.TestJoinElection()
      /opt/code/go/pkg/mod/github.com/docker/libkv@v0.2.1/libkv.go:39 +0xfd
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:865 +0x163

Previous write at 0x00c00008b198 by goroutine 8:
  github.com/kmulvey/scratch/election.TestJoinElectionFail()
      /opt/code/go/pkg/mod/github.com/docker/libkv@v0.2.1/libkv.go:39 +0xf7
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:865 +0x163

https://github.com/docker/libkv/blob/458977154600b9f23984d9f4b82e79570b5ae12b/libkv.go#L39