Let's say I am having one Primary (A) & two secondary (B, C). If I am doing write using write majority. Can some one please explain my below doubts:-
majority and it updated the data in A & B and the write did not yet propagate to C. At this time if a read comes for the same data using secondary or secondary preferred will the query be served from B which is having the latest data or mongo cannot gurantee this and the read may return a stale data from C.A and then a write is on progress in one of the secondary B. If a read comes at that time will the read be blocked or it will serve a stale data from C?C and the same case is in progress as we mentioned in the above case. Will the read from secondary B be blocked till the write is complete on B or the read will not be blocked and a stale data will be served from B?Environment
Hi D,
- Let’s say a write was done using majority and it updated the data in A & B and the write did not yet propagate to C. At this time if a read comes for the same data using secondary or secondary preferred will the query be served from B which is having the latest data or mongo cannot gurantee this and the read may return a stale data from C.
The reads in the above scenario can be received by any of the secondaries, B or C. In case non- primary read preferences are specified, there is a chance of stale reads because with the asynchronous replication, data in secondary may not reflect the most recent write operations.
However, In 3.2, this can be mitigated by Read Concern ‘majority’ setting .
- Let’s say a write was done using majority again and let’s say the write was done on A and then a write is on progress in one of the secondary B. If a read comes at that time will the read be blocked or it will serve a stale data from C?
You can also refer to Multithreaded Replication Page for more information on secondary read behaviour with replication.
- Let’s say I have taken out the secondary C and the same case is in progress as we mentioned in the above case. Will the read from secondary B be blocked till the write is complete on B or the read will not be blocked and a stale data will be served from B?
Taking node C offline does not alter the behaviour of node B for secondary reads.
In general, using secondary reads in a replica set must be done with careful planning, since it could interfere with the main purpose of a replica set, which is high availability.
For more information, please see:
Regards,
Pooja
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/q_ap33UTDS8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/97b772ac-3e11-48c4-9e6b-bf8b49214deb%40googlegroups.com.