Day07 as #100DaysofMongoDB as #100daysofcode
We discussed a few concepts on Write concern in my previous post, for this post, we will begin with read concern.
A Read concern is specified to determine the level of consistency in any replica set. There are 5 types of Reads concern which are common:
- Local: This reads the data from most recent snapshot of the storage engine.
- Majority: This reflects the entries that have been replicated to a majority of nodes .
- Snapshot: Only accessible in the multi-document transaction.
- Available: This works similar to local read concern.
- afterOpTime: This means that read will block until the node has replicated writes after a certain OpTime.
For multi-document transaction, which write concern will be preferred and why?
By default the read concern is set to local. Showing similar kind of logic as local, the available read concern is not preferred.
The Local read concern waits to refresh the routing table when it identifies a stale data and hence maintains the consistency, however, the available read concern, does not provide consistency as it does not wait for cache to be refreshed. This also means that the available read concern would has the potential to return orphan documents.
The selection of read concern will entirely depend on the architecture of the replica set.
Will be continuing more on replication in the upcoming post.
Thanks
Aasawari