Merge lp://staging/~mfoord/juju-core/slow-replset into lp://staging/~go-bot/juju-core/trunk

Proposed by Michael Foord
Status: Merged
Approved by: Michael Foord
Approved revision: no longer in the source branch.
Merged at revision: 2819
Proposed branch: lp://staging/~mfoord/juju-core/slow-replset
Merge into: lp://staging/~go-bot/juju-core/trunk
Diff against target: 81 lines (+46/-0)
2 files modified
replicaset/replicaset.go (+17/-0)
replicaset/replicaset_test.go (+29/-0)
To merge this branch: bzr merge lp://staging/~mfoord/juju-core/slow-replset
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+221709@code.staging.launchpad.net

Commit message

replicaset/initiate: wait for status from initiate

After replicaset initiation wait (briefly) for a
status check to return successfully. Hopefully this
will fix the problems with bootstrap on precise for
slow machines. It also means we won't attempt to
use the database until we know the replicaset is
ready.

Description of the change

replicaset/initiate: wait for status from initiate

After replicaset initiation wait (briefly) for a
status check to return successfully. Hopefully this
will fix the problems with bootstrap on precise for
slow machines. It also means we won't attempt to
use the database until we know the replicaset is
ready.

https://codereview.appspot.com/104800043/

To post a comment you must log in.
Revision history for this message
Michael Foord (mfoord) wrote :

Reviewers: mp+221709_code.launchpad.net,

Message:
Please take a look.

Description:
replicaset/initiate: wait for config from initiate

After replica set initiation wait (briefly) for a
config check to return successfully. Hopefully this
will fix the problems with bootstrap on precise for
slow machines.

https://code.launchpad.net/~mfoord/juju-core/slow-replset/+merge/221709

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/104800043/

Affected files (+19, -0 lines):
   A [revision details]
   M replicaset/replicaset.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140602083040-w9o6gm2nvydmo7u1
+New revision: <email address hidden>

Index: replicaset/replicaset.go
=== modified file 'replicaset/replicaset.go'
--- replicaset/replicaset.go 2014-05-30 00:31:44 +0000
+++ replicaset/replicaset.go 2014-06-02 11:18:12 +0000
@@ -23,6 +23,10 @@
   // attempts to replSetInitiate.
   initiateAttemptDelay = 100 * time.Millisecond

+ // initiateConfigDelay is the amount of time to sleep between failed
+ // attempts to get the replicaset config after initiate
+ initiateConfigDelay = 500 * time.Millisecond
+
   // rsMembersUnreachableError is the error message returned from mongo
   // when it thinks that replicaset members are unreachable. This can
   // occur if replSetInitiate is executed shortly after starting up mongo.
@@ -64,6 +68,19 @@
    }
    break
   }
+
+ var config *Config
+ for i := 0; i < maxInitiateAttempts; i++ {
+ config, err = CurrentConfig(monotonicSession)
+ if err != nil {
+ logger.Warningf("Initiate: fetching config failed: %v", err)
+ }
+ if err != nil || len(config.Members) == 0 {
+ time.Sleep(initiateConfigDelay)
+ continue
+ }
+ break
+ }
   return err
  }

Revision history for this message
William Reade (fwereade) wrote :

https://codereview.appspot.com/104800043/diff/1/replicaset/replicaset.go
File replicaset/replicaset.go (right):

https://codereview.appspot.com/104800043/diff/1/replicaset/replicaset.go#newcode74
replicaset/replicaset.go:74: config, err =
CurrentConfig(monotonicSession)
I am strongly inclined to suggest mocking CurrentConfig for ease of
testing this...

https://codereview.appspot.com/104800043/

Revision history for this message
Michael Foord (mfoord) wrote :
Revision history for this message
Michael Foord (mfoord) wrote :
Revision history for this message
Nate Finch (natefinch) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: