Have anyone implemented Mongo replication using replset arbiter. At the time of fail-over from Primary to Secondary, Arbiter should bring down VIP on primary and enable on secondary when Arbiter appoints secondary as Master.

Is this is possible?

I do understand that it is for voting purpose. But when it can decide who should be available for writes and who shouldn't be, I would like to embed a logic that should also route application requests to the winner. Also I don't want to keep the host decision on app end. Kinda doesn't look clean for me.

Note: It will open write on secondary, doesn't mean that it will route the requests from application to secondary (NewMaster).

So the drivers here are application drivers should be written in such a way.

@mongo_client = MongoReplicaSetClient.new(
['n1.mydb.net:27017', 'n2.mydb.net:27017', 'n3.mydb.net:27017']

To choose its member. I'm I right?


1 Answer 1


Community Wiki answer generated from comments on the question by James Wahlin and Markus W Mahlberg

James: The arbiter is a voting member in an election but doesn't appoint members as primary or control the process. I would suggest reading: Replica Set Elections in the MongoDB manual.

When there is an election, all client connections are dropped by MongoDB. At that point in time the client will connect to one of its seeds and perform an isMaster call. This call reports back to the client which member is primary and which members are secondaries. In that way the client will seamlessly write to the correct member, based on read preference.

Markus: It will route requests from the application to the secondary. The drivers are replica set aware. Since all connections are either actively dropped by the old primary or stale, the driver will try to find the current primary in the list of replica set members it knows. You can verify this behaviour by setting up a replica set locally, running at 3 different ports on your local machine and kill one of them at random. After the short while an election needs to be finished, your client application writes to the newly elected primary.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.