Skip to content

Data race for socket #135

Closed
Closed
@kirik

Description

@kirik

Hello! I got race condition randomly. Here is stack:

WARNING: DATA RACE
Read at 0x00c4201381b8 by goroutine 94:
  github.com/globalsign/mgo.(*Session).acquireSocket()
      /.../github.com/globalsign/mgo/session.go:4822 +0x768
  github.com/globalsign/mgo.(*Database).Run()
      /.../github.com/globalsign/mgo/session.go:799 +0x6d
  github.com/globalsign/mgo.(*Session).Run()
      /.../github.com/globalsign/mgo/session.go:2270 +0xc3
  github.com/globalsign/mgo.(*mongoCluster).isMaster()
      /.../github.com/globalsign/mgo/cluster.go:182 +0x27c
  github.com/globalsign/mgo.(*mongoCluster).syncServer()
      /.../github.com/globalsign/mgo/cluster.go:231 +0x457
  github.com/globalsign/mgo.(*mongoCluster).syncServersIteration.func1.1()
      /.../github.com/globalsign/mgo/cluster.go:553 +0x200

Previous write at 0x00c4201381b8 by goroutine 33:
  github.com/globalsign/mgo.(*mongoSocket).kill()
      /.../github.com/globalsign/mgo/socket.go:351 +0x251
  github.com/globalsign/mgo.(*mongoSocket).resetNonce.func1()
      /.../github.com/globalsign/mgo/auth.go:123 +0x135
  github.com/globalsign/mgo.(*mongoSocket).readLoop()
      /.../github.com/globalsign/mgo/socket.go:628 +0x1101

Goroutine 94 (running) created at:
  github.com/globalsign/mgo.(*mongoCluster).syncServersIteration.func1()
      /.../github.com/globalsign/mgo/cluster.go:525 +0x174
  github.com/globalsign/mgo.(*mongoCluster).syncServersIteration()
      /.../github.com/globalsign/mgo/cluster.go:580 +0x54b
  github.com/globalsign/mgo.(*mongoCluster).syncServersLoop()
      /.../github.com/globalsign/mgo/cluster.go:390 +0x18e

Goroutine 33 (running) created at:
  github.com/globalsign/mgo.newSocket()
      /.../github.com/globalsign/mgo/socket.go:197 +0x392
  github.com/globalsign/mgo.(*mongoServer).Connect()
      /.../github.com/globalsign/mgo/server.go:183 +0x60c
  github.com/globalsign/mgo.(*mongoServer).AcquireSocket()
      /.../github.com/globalsign/mgo/server.go:129 +0x349
  github.com/globalsign/mgo.(*mongoCluster).syncServer()
      /.../github.com/globalsign/mgo/cluster.go:225 +0x2a5
  github.com/globalsign/mgo.(*mongoCluster).syncServersIteration.func1.1()
      /.../github.com/globalsign/mgo/cluster.go:553 +0x200
==================

I can't reproduce it. But I believe, that we need to Lock mutex for s.masterSocket on /.../globalsign/mgo/session.go:4822 before read dead property. Am I right?

Му OS is Ubuntu 16.04 and GO version is 1.9.2 linux/amd64.

Thank you in advance!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions