Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1234

Deadlock on 1.1.0 release

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.2.0
    • Affects Version/s: None
    • Component/s: Core API
    • None

      We recently attempted to upgrade to the 1.1.0 release and one of our tests caught a deadlock in Topology.Connect.

      goroutine 4 [semacquire]:
      sync.runtime_SemacquireMutex(0xc0002461d0, 0x0)
          /usr/local/Cellar/go/1.12.7/libexec/src/runtime/sema.go:71 +0x3d
      sync.(*Mutex).Lock(0xc0002461cc)
          /usr/local/Cellar/go/1.12.7/libexec/src/sync/mutex.go:134 +0x109
      go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Topology).apply(0xc000246140, 0x17427a0, 0xc0000ca008, 0xc0000aac40, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go:526 +0x54
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Topology).addServer.func1(0xc0000aac40, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000174820, 0xf, 0xffffff7f, ...)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go:578 +0x81
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).updateDescription(0xc0002461e0, 0xc0000aac40, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000174820, 0xf, ...)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go:431 +0x2d4
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.NewServer.func1(0xc0000aac40, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000174820, 0xf, 0xffffff7f, ...)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go:146 +0x70
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.newConnection(0x17427a0, 0xc0000ca000, 0xc0000aac40, 0xf, 0xc0001f06c0, 0x7, 0xc, 0xdf8475800, 0x8, 0x1601978)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go:106 +0x727
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).makeNewConnection(0xc0001f0720, 0x17427a0, 0xc0000ca000, 0xc000001500, 0xc0000ce600, 0x3, 0x104ca01, 0x105f390)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go:266 +0x73
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).connectionInitFunc(0xc0001f0720, 0x104db3c, 0x1b0b340)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go:124 +0x44
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*resourcePool).add(0xc0001ee370, 0x0)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/resource_pool.go:99 +0xf4
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*resourcePool).Maintain(0xc0001ee370)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/resource_pool.go:176 +0xf8
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*resourcePool).initialize(0xc0001ee370)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/resource_pool.go:92 +0xb0
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).connect(...)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go:190
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).Connect(0xc0002461e0, 0xc000230380, 0xc00022a4e0, 0x3)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go:172 +0x16f
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.ConnectServer(0xc0000aac40, 0xf, 0xc000230380, 0xc00022a4e0, 0x3, 0x4, 0x0, 0x1, 0xc0002aa000)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go:113 +0x86
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Topology).addServer(0xc000246140, 0xc0000aac40, 0xf, 0x0, 0x1)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go:580 +0xd2
      git.corp.stripe.com/stripe-internal/gocode/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Topology).Connect(0xc000246140, 0x1, 0x1)
          go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go:138 +0x209
      

      It looks like Topology.Connect takes out a lock on Topology.serversLock and calls Topology.addServer, but then Topology.addServer is recursively called, and calls Topology.apply, which also takes a lock on Topology.serversLock.

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            bartle David Bartley
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: