Search code examples
mongodbreplicasetmongodb-replica-setdatabase

what happends to a write request to Mongo cluster, during Mongo primary stepdown and election


I have an application constantly writing to a MongoDB replica set (for example 1 primary, 2 secondary).

I'm wondering: if I force current primary to step down, then an election for new primary could take a couple seconds to finish.

But during this election process, if there are still write requests to MongoDB, what happens to the write request?

As I understand it, any read request should be OK, but all writes have to go through the primary; but if a cluster doesn't have one, then the write request will be either queued, or dropped?

https://docs.mongodb.com/manual/reference/method/rs.stepDown/ https://docs.mongodb.com/manual/core/replica-set-elections/


Solution

  • You'll get an error until a new master is elected. You'd have to manage queuing in your application, otherwise dropped.