We’ve been extensively testing MongoDB against causal consistency, following the config given at https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/#std-label-sessions (e.g., majority reads + majority writes).
The causal consistency property we have been checking is actually a stronger notion (see below) of causal consistency claimed by MongoDB. So far, we found NO violation. This roused our curiosity: What exactly the causal consistency guarantee MongoDB actually implements?
*** Background on causal consistency (CC) ***
There are several notions of CC in the literature.
The weakest notion of CC, currently claimed by MongoDB, is considered as a combination of four session guarantees: “Read your writes”, “Monotonic reads”, “Monotonic writes”, and “Writes follow reads”. See the above link for details.
A stronger notion of CC, adopted by many industrial and academic cloud DBs, is called causal+, originally proposed (as far as I know) in the SOSP’11 paper “Don’t Settle for Eventual: Scalable Causal Consistency for Wide-Area Storage with COPS”. In addition to the above four guarantees, causal+ takes into account convergent conflict handling. More specifically, I quote the definition from the POPL’17 paper “On verifying causal consistency”:
“There is a total order between non-causally dependent operations and each site can execute operations only in that order (when it sees them). Therefore, a site is not allowed to revise its ordering of non-causally dependent operations, and all sites execute in the same order the operations that are visible to them.”
Causal+ is definitely more attractive. Below is an example taken from the SOSP paper:
" … consider an example where Carol and Dan both update the starting time for an event. The time was originally set for 9pm, Carol changed it to 8pm, and Dan concurrently changed it to 10pm. Regular causal consistency would allow two different replicas to forever return different times, even after receiving both put operations. Causal+ consistency requires that replicas handle this conflict in a convergent manner. If a last-writer-wins policy is used, then either Dan’s 10pm or Carol’s 8pm would win …"
*** End ***
A quick takeaway from the SOSP paper is that “last-writer-wins” can handle convergent conflict. Coincidently, I found sth interesting here https://docs.mongodb.com/realm/sync/learn/conflict-resolution/ MongoDB claims to support “Last update wins”, though I haven’t got time to connect it to MongoDB’s causal consistency implementation.
It would be great to clarify this issue to benefit MongoDB applications! Thanks!