Race in mgo Stats implementation

Bug #1604817 reported by Curtis Hovey
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Reed O'Brien

Bug Description

As seen at
    http://reports.vapour.ws/releases/issue/578f7bf1749a567c7344833e

The is a race in github.com/juju/juju/featuretests

WARNING: DATA RACE
Read by goroutine 53:
  gopkg.in/mgo%2ev2.(*mongoSocket).kill()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/mgo.v2/socket.go:329 +0x7e5
  gopkg.in/mgo%2ev2.(*mongoSocket).Close()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/mgo.v2/socket.go:316 +0xd9
  gopkg.in/mgo%2ev2.(*mongoServer).Close()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/mgo.v2/server.go:199 +0x35f
  gopkg.in/mgo%2ev2.(*mongoCluster).Release()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/mgo.v2/cluster.go:101 +0x352
  gopkg.in/mgo%2ev2.(*mongoCluster).syncServersLoop()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/mgo.v2/cluster.go:363 +0x370

Previous write by goroutine 132:
  gopkg.in/mgo%2ev2.ResetStats()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/mgo.v2/stats.go:59 +0x17e
  github.com/juju/testing.(*MgoSuite).SetUpTest()
      /home/ubuntu/juju-core_2.0-beta13/src/github.com/juju/testing/mgo.go:618 +0x41
  github.com/juju/juju/juju/testing.(*JujuConnSuite).SetUpTest()
      /home/ubuntu/juju-core_2.0-beta13/src/github.com/juju/juju/juju/testing/conn.go:121 +0x4c
  github.com/juju/juju/featuretests.(*syslogSuite).SetUpTest()
      /home/ubuntu/juju-core_2.0-beta13/src/github.com/juju/juju/featuretests/syslog_test.go:109 +0x2b4
  runtime.call32()
      /usr/lib/go-1.6/src/runtime/asm_amd64.s:472 +0x3d
  reflect.Value.Call()
      /usr/lib/go-1.6/src/reflect/value.go:303 +0xcd
  gopkg.in/check%2ev1.(*suiteRunner).runFixture.func1()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/check.v1/check.go:721 +0x1b8
  gopkg.in/check%2ev1.(*suiteRunner).forkCall.func1()
      /home/ubuntu/juju-core_2.0-beta13/src/gopkg.in/check.v1/check.go:666 +0x80

Changed in juju-core:
assignee: nobody → Reed O'Brien (reedobrien)
summary: - Race in github.com/juju/juju/featuretests
+ Race in github.com/juju/juju/featuretests/syslog_test
Changed in juju-core:
status: Triaged → In Progress
Revision history for this message
Reed O'Brien (reedobrien) wrote : Re: Race in github.com/juju/juju/featuretests/syslog_test

Looking into mgo. There appeared to be a data race in the way Stats are implemented. menn0 confirmed and suggested a fix. Without the fix I managed to reproduce the race twice in a couple hours of running.

Last night I left a script running to stress feature tests with a fix. It didn't trigger overnight.

Currently the patch doesn't change the outcome of tests in gopkg.in/mgo.v2. However, gopkg.in/mgo.v2-unstable is where new fixes would be applied so I created a branch there and am testing against that and running a script to stress feature tests with mgo.v2-unstable.

So a little bit of polish and I'll make a PR against mgo in github.

Revision history for this message
Reed O'Brien (reedobrien) wrote :

NOTE: mgo.v2-unstable has changed from using chrism's python supervisor to djb's supervisor. So in unstable you need to `apt-get install daemontools-run` in order to run the tests.

sudo apt-get install daemontools-run

make startdb; go test; make stopdb

Of course if you want to inspect the artifacts after the test run don't make stopdb as it cleans up said artifacts. WRT artifacts in unstable they are now in a _harness directory rather than a _testdb directory.

Revision history for this message
Reed O'Brien (reedobrien) wrote :

fix proposed https://github.com/go-mgo/mgo/pull/303

We'll see if it breaks the build...

Revision history for this message
Reed O'Brien (reedobrien) wrote :

If the fix is accepted we'll need to either wait until it lands in mgo.v2, pin against v2-unstable, vendor, or maintain a patch. I don't know our MO.

Revision history for this message
Reed O'Brien (reedobrien) wrote :

I decided it would be wise to run the mgo tests with the race flag. The change we made created a new race in mgo. This is now fixed, too. Same PR https://github.com/go-mgo/mgo/pull/303

Revision history for this message
Reed O'Brien (reedobrien) wrote :

Menno is reaching out to gustavo for another mgo issue and said he'll also bring this to his attention.

Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta13 → 2.0-beta14
Curtis Hovey (sinzui)
tags: removed: blocker
Curtis Hovey (sinzui)
Changed in juju-core:
importance: Critical → High
Revision history for this message
Anastasia (anastasia-macmood) wrote :

New mgo has been released - https://twitter.com/gniemeyer/status/760472159256993792.

We need to update our dependencies.

Curtis Hovey (sinzui)
Changed in juju-core:
milestone: 2.0-beta14 → 2.0-beta15
Revision history for this message
Menno Finlay-Smits (menno.smits) wrote :

The new mgo release doesn't appear to contain the fix for this issue. The PR hasn't been accepted and the stable branch doesn't have the fix.

summary: - Race in github.com/juju/juju/featuretests/syslog_test
+ Race in mgo Stats implementation
Revision history for this message
Menno Finlay-Smits (menno.smits) wrote :

I've generalised the bug title as this issue can happen in almost any Juju test which uses MongoDB.

Changed in juju-core:
milestone: 2.0-beta15 → 2.0-beta16
affects: juju-core → juju
Changed in juju:
milestone: 2.0-beta16 → none
milestone: none → 2.0-beta16
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-beta16 → 2.0-beta17
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-beta17 → 2.0-beta18
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-beta18 → 2.0-beta19
Changed in juju:
milestone: 2.0-beta19 → 2.0-rc1
Changed in juju:
milestone: 2.0-rc1 → 2.0-rc2
Revision history for this message
Reed O'Brien (reedobrien) wrote :

Upstream isn't moving, so this has been added to the patches directory and should be applied on CI test runs.

Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-rc2 → none
Changed in juju:
milestone: none → 2.0.0
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-rc3 → 2.0.0
Changed in juju:
milestone: 2.0.0 → 2.0.1
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0.1 → none
Curtis Hovey (sinzui)
Changed in juju:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.