1

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?

1 Answer 1

0

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.

db.products.insert(
   { item: "envelopes", qty : 100, type: "Clasp" },
   { writeConcern: { w: 2, wtimeout: 5000 } }
)
0

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.