Fork me on GitHub

Hey guys, got a little question regarding Datomic and Consistency. The official website claims that Datomic is consistent in both the ACID and CAP senses, now the ACID one I can understand since we have serialised transactions but how does it achieve consistency in the CAP sense if we have an eventually consistent storage backend? The C in CAP states that "Every read receives the most recent write or an error".


The stuff written is immutable


So if a peer gets an error for a key, it knows the storage just doesn’t have it yet. But if it gets a value, it knows the value will never change


There are still a small number of keys (less than ten) that are updated—they store root pointers. The storage impl makes sure they’re written with stronger consistency


The supported storages aren’t only eventually consistent, they have stronger modes


But is it guaranteed that you'll always get the latest "db value" when you do (datomic.api/db conn) ?


Where they do not (eg riak) another db is used for those mutable keys (eg zookeeper)


It is guaranteed you will always get a consistent snapshot


Not the “latest-latest “ because physics


You can use the sync functions if you need to ensure you are caught up to a specific db t


Cool, never knew there was a sync function, let me check out the docs 🙂


This is an issue when you have out of band communication


Eg one of your servers saw db at time t, and sent something to another which expects to read at least the same db value or newer


The msg from the other server may have gotten to you faster than the new db valu


If you transmit the t also you can use sync to ensure you are at least as far along as the server that sent the message


Ok so if I were to need to coordinate some actions between services, I would have to send the time-basis for the previous tx in my message then use sync, is that correct?


You would if you need the other service to read the same data out of the same db


gotcha, thanks! 🙂


I'm not actually building any sort of distributed system at the moment but was just thinking about that case that causal information from a user's interaction could be lost in a distributed system.


Yeah that’s taken care of between a peer and the storage+transactor, but not among peers (which is what sync is for)