Skip to content

Commit

Permalink
Wait for each RS to elect a primary
Browse files Browse the repository at this point in the history
In a sharded replica set, wait for each of the shards to elect
a primary before continuing to hopefully fix rueckstiess#691
  • Loading branch information
p committed Feb 14, 2020
1 parent 88f72aa commit 84f4f70
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mtools/mlaunch/mlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,10 @@ def _initiate_replset(self, port, name, maxwait=30):
% (name, self.config_docs[name]))
print("replica set '%s' initialized." % name)

print("waiting for localhost:%i to elect a primary" % port)
con = self.client(['localhost:%i' % port], replicaSet=name, serverSelectionTimeoutMS=30000)
con['admin'].command({'ping': 1})

def _add_user(self, port, name, password, database, roles):
con = self.client('localhost:%i' % port)
v = con['admin'].command('isMaster').get('maxWireVersion', 0)
Expand Down

0 comments on commit 84f4f70

Please sign in to comment.