Skip to content

Commit

Permalink
Fsync mongo so new lease queries are up to date
Browse files Browse the repository at this point in the history
Mongo doesn't know about our clock implementation. So even though we've
advanced our clock we might not have waited for mongo to write the
changes to disk before asking for the expired leases and trying to
claim a new one.

I was able to reproduce this pretty easily within 100 or so runs. With
mgo.Session.Fsync I haven't triggered it within ~3000 runs.

Fixes https://bugs.launchpad.net/juju/+bug/1614256
  • Loading branch information
reedobrien committed Sep 27, 2016
1 parent c5ffc0d commit e0b6aaa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions state/state_leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (s *LeadershipSuite) TestHackLeadershipUnblocksClaimer(c *gc.C) {

func (s *LeadershipSuite) expire(c *gc.C, applicationname string) {
s.clock.Advance(time.Hour)
s.Session.Fsync(false)
select {
case err := <-s.expiryChan(applicationname):
c.Assert(err, jc.ErrorIsNil)
Expand Down

0 comments on commit e0b6aaa

Please sign in to comment.