Majority write concern with respect to read concern

Hi,

We are using WC:majority with our applications, do we need to use read-concern majority as well.
How read will work in this case.

Hi :wave: @Aayushi_Mangal,

It depends on the specific requirements of your application.

"Read concern majority" is a read concern that ensures that a read operation will only return data that has been written to a majority of replica set members. By default, MongoDB reads from a single replica set member, so using “read concern majority” will result in slower read performance, but will ensure that the data returned is consistent across the majority of replica set members.

If consistency is important for your application, it may be necessary to use "read concern majority" in addition to "WC: majority." However, if read performance is more important, you may choose not to use “read concern majority” and instead rely on the built-in replication in MongoDB to eventually propagate the data to all replica set members.

Visit docs to read more about it:

Please let us know if you have any follow-up questions on this, and share the use case and the goal.

Thanks,
Kushagra

1 Like

Thank @Kushagra_Kesav , I had read somewhere that the secondary reads provide the latest Oplog, but the fact is it get reads from the nearest/fastest (may or may not get stale)

So to get latest document we need to go for write Concern Majority along with read concern level majority, is that correct?

Hi @Aayushi_Mangal,

It will be more helpful if we understand your use cases and it’s not recommended to read oplogs directly, primary, or secondary since it’s for MongoDB internal use. If the app needs to follow a collection/database/server changes, then using change-stream is the supported approach.

Not 100% correct, since there are nuances to this. Write majority implies that the document has propagated to the majority of voting nodes. Read majority means return the latest document that is majority committed.

Those two documents may or may not be the same document due to the nature of a distributed system. Again what is the use case? If it’s read-your-writes then you need causal consistency. Write majority + read majority is not a direct replacement for that.

Read more about Read Concern “Majority”

Please let us know if you have any follow-up questions.

Thanks,
Kushagra