Update with Write Concern parameter

I have a philosophical doubt about update with write concern and future read.

In a scenario of a replica set with 3 nodes, if we make an update with write concern parameter se as “majority” the data is being updated in 2 nodes, before responding the ack. But, what happens if we read the data from the third node, when it is not correctly updated?

What’s the data fiability of our read?

Furthermore, the udpdate will be replicated to the 3rd node?

Best,
Rosa

Hi there,

This is a very good question. Thankfully, MongoDB allows you to specify read concerns when reading data from a replica set.

The default read concern for secondary reads is read concern “local”. This will return data with no guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back).

As with write concerns, you can specify read concern majority, which will only read data which has been committed to the majority of nodes in the replica set.

You can read more about read concerns in our documentation here:

https://docs.mongodb.com/manual/reference/read-concern/

Thanks for your response.

I have another question, when an application reads with read concern “majority”, has Mongo, under a 3 node replica set scenario, the ability to chose the right nodes which can serve the last updated data?

Thanks for all

By default, you will read from a primary. You can also specify a read preference, which specifies which node you will read from. You can read more about read concerns here in our docs:

https://docs.mongodb.com/manual/reference/read-concern/