--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/18a65908-7c6d-4be4-994e-81cc79ec9172%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/8b7da0b9-db33-4290-9e53-cad5879e71ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAOe6dJDdfSjxQNW1Wtz%3DvZAKUEA5KowFSTvjRWM%2BR_q7kOL3pA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/61819e5a-374e-4546-b29b-5f2aa115b66b%40googlegroups.com.
Scott:
> what is the maximum amount of time
In practical terms, it will depend on the version of mongod and the driver. Elections, step-down, these things are tied to various changes we've made over versions. We've been working toward shorter failover times and better election protocol which will allow the drivers to recognize immediately in face of two primaries which one is "legit". So if using next version with read committed and latest driver and you are talking about a single application (single connection pool really, where the driver can invalidate old primary on all connections as soon as it sees a higher election id) then it could probably be reduced to close to no time - but that may not be scenario for large complex applications - driver cannot invalidate *other* connections to old primary, only *it* can do that, based on realizing it's not primary. [2] So in that case we may be talking about seconds.
> How rare is this scenario
Hard to say. Kyle has an excellent post on " how rare are network partitions" and I'm inclined to point you at it, as it's a pretty fun read. [1]. Having said that, I'm not sure that it's correct to limit your thinking to network partitions only. Two primaries can transiently happen any time there is an election by majority when the existing primary has not stepped down. This can happen when the network truly partitions off part of the replica set, but it can also happen when primary if not responding to heartbeats for any other reason. Possible reasons: its server is overloaded, its server is frozen, someone mis-configured the network switch asymmetrically (no one in the replica set can see the primary but it can see everyone), someone accidentally sent SIGTSTP to primary process, etc.
> how best to [ defend against it on application level ]
In certain scenarios you use findAndModify to do your reads - what you already do when implementing a queue or "global" sequential counter. As long as you wait to use the value returned till majority write concern was satisfied you would be guaranteed that this primary gave you a non-stale value.
I'm sure there will be others in the future - read-as-write can be used with any version.
A non-workaround that nonetheless "works" would be to consider if stale read is more important to prevent for a particular application than having high availability. If you think yes, then you can disable automatic fail over (and assume that manual fail over will never do the wrong thing which I personally would not). I'm inclined to think that given users are always asking for faster failover, lower latency reads/writes, multimaster, etc, since those are all more likely to create weaker consistency, either those users' applications are not concerned with stale reads, or . . .
Asya
[1] https://aphyr.com/posts/288-the-network-is-reliable
[2] maybe someone can figure out a way any driver that sees a higher election id can tell the old primary it needs to check if it's really still primary. Like, if addition to isMaster it can send command like isMasterStill, ohReally, areYouSureIsMaster, or doubleCheckPlease :)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/33b7da9a-ce2c-41bb-b9b1-353e5db37bc5%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/2df06acc-c0e8-4576-b44c-e553ba36df63%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/38bde5f8-22db-4fad-9477-e411f72a422f%40googlegroups.com.