mongodb - Compare consistency models used in mgo -


mongodb servers queried multiple consistency rules. in mgo, setmode of session object changes consistency mode session. 3 types of consistency modes available: eventual, monotonic, , strong.

e.g.

session, err := mgo.dial("localhost") if err != nil {     panic(err) } defer session.close() //switch session monotonic behavior. session.setmode(mgo.monotonic, true) 

i reading different consistency models in https://en.wikipedia.org/wiki/consistency_model

but relations between 3 models used in mgo?

is correct strong implies eventual, , eventual implies monotonic?

thanks.

these 3 consistency models mongodb claims support:

  • strong consistency: accesses seen parallel processes (or nodes, processors, etc.) in same order (sequentially).

  • monotonic reads: if process reads value of data item x, successive read operation on x process return same value or more recent value.

  • eventual consistency: if no new updates made given data item, accesses item return last updated value.

by these definitions, strong implies eventual, , strong implies monotonic, there no relation between eventual consistency , monotonic reads.

however, looking @ real system, there more found.

in mongodb, monotonic mode means client opens single connection secondary node. reads happen through connection. when write happens, client drops connection , connects primary node, , performs write. reads following write performed primary node.

in eventual mode, reads done multiple secondary nodes, concurrently. means might see updates out of order, reach different nodes. writes performed against primary, possibly in multiple concurrent connections. means writes may arrive out of order well. not clear documentation if reads following first write served primary, in monotonic mode, or if continue served secondaries. the source code, however, tells reads continue served secondaries.

// switch on monotonic session master. if !slaveok && s.consistency == monotonic {     s.slaveok = false } 

thus, mgo v2, strong implies monotonic implies eventual.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -