This is actually expected behaviour:
https://docs.mongodb.org/v3.0/reference/method/rs.stepDown/#behavior
The rs.stepDown()
disconnects current clients (including the shell connection you are running this command from) to ensure clients have an accurate view of the replica set. If you run another command in the mongo
shell it should automatically reconnect and discover the current replica set configuration.
You said: " If you run another command in the mongo shell, it should automatically reconnect.."
I am not sure what you mean ? are you saying to run rs.stepDown() from mongS or form config server ? what command are you referring to ?
rs0:PRIMARY> rs.stepDown()
2015-09-24T15:51:40.390-0500 DBClientCursor::init call() failed
2015-09-24T15:51:40.391-0500 Error: error doing query: failed at src/mongo/shell/query.js:81
2015-09-24T15:51:40.395-0500 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2015-09-24T15:51:40.395-0500 reconnect 127.0.0.1:27017 (127.0.0.1) ok
The rs.stepDown()
disconnected your active session and there was an error on the next query. The mongo
shell then tried to reconnect (and succeeded).
In general, if your mongo
shell connection is dropped the next command you run will automatically try to reconnect.
Hi AJ,
The disconnection on rs.stepDown() is expected (not an error).
Your prompt on rs0 changed from "primary" to “secondary”. Was this member re-elected as a primary afterward?
You can make the current host ineligible to become primary for a period of time using the rs.freeze()
command:
http://docs.mongodb.org/v3.0/reference/method/rs.freeze/
You can also influence which member is elected primary by adjusting the priority values:
http://docs.mongodb.org/manual/tutorial/adjust-replica-set-member-priority/
Regards,
Stephen
I think the error message is misleading. server-1.com has always been PRIMARY and still PRIMARY regardless after I ran stepDown few times.