Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait longer for replicaset initiation to complete #12

Merged
merged 2 commits into from
Jun 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions replicaset/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ const (

// maxInitiateStatusAttempts is the maximum number of
// attempts to get the replicaset status after initiate
maxInitiateStatusAttempts = 50
maxInitiateStatusAttempts = 60

// initiateStatusDelay is the amount of time to sleep between failed
// attempts to fetch the status of the replica set after initiate
initiateStatusDelay = 250 * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be used anywhere?


// 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.
rsMembersUnreachableError = "all members and seeds must be reachable to initiate set"

// rsReceivedInitiateError is the error message returned from mongo
// when it has received the instruction to initiate but has not yet
// completed. We just need to wait for it to complete.
rsReceivedInitiateError = "Received replSetInitiate - should come online shortly"
)

var logger = loggo.GetLogger("juju.replicaset")
Expand Down Expand Up @@ -74,10 +83,12 @@ func Initiate(session *mgo.Session, address, name string, tags map[string]string
monotonicSession.Refresh()
status, err := getCurrentStatus(monotonicSession)
if err != nil {
logger.Warningf("Initiate: fetching replicaset status failed: %v", err)
if !strings.Contains(err.Error(), rsReceivedInitiateError) {
logger.Warningf("Initiate: fetching replicaset status failed: %v", err)
}
}
if err != nil || len(status.Members) == 0 {
time.Sleep(initiateAttemptDelay)
time.Sleep(initiateStatusDelay)
continue
}
break
Expand Down