Suppose We have a replica set with 1 primary and 2 secondaries.

During write operation on Primary, will write commit happen at once upon finishing write operation on primary and before spreading changes to secondaries? Or it will happen once all changes will be apllied on secondaries?


This can be specified for every write operation:

From the docs about Verify Write Operations to Replica Sets:

For a replica set, the default write concern requests acknowledgement only from the primary. You can, however, override this default write concern, such as to confirm write operations on a specified number of the replica set members.


To override the default write concern, specify a write concern with each write operation. For example, the following method includes a write concern that specifies that the method return only after the write propagates to the primary and at least one secondary or the method times out after 5 seconds.

   { item: "envelopes", qty : 100, type: "Clasp" },
   { writeConcern: { w: 2, wtimeout: 5000 } }
| improve this answer | |
  • You're welcome. If you think this answers your question, it is customary to mark it as accepted, so that people can concentrate on unanswered questions. – joanolo Jul 2 '17 at 11:42
  • I don't have enough votes to close it. – user54 Jul 2 '17 at 11:43
  • You should be able to accept it, a little mark under the down arrow from the answer. See How does accepting an answer work?. You might just have to wait a few minutes ;-) – joanolo Jul 2 '17 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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