Fork me on GitHub
#datomic
<
2018-05-12
>
akiroz09:05:29

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".

favila14:05:40

The stuff written is immutable

favila14:05:28

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

favila14:05:33

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

favila14:05:10

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

akiroz14:05:37

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

favila14:05:47

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

favila14:05:04

It is guaranteed you will always get a consistent snapshot

favila14:05:22

Not the “latest-latest “ because physics

favila14:05:38

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

akiroz14:05:29

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

favila14:05:36

This is an issue when you have out of band communication

favila14:05:33

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

favila14:05:04

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

favila14:05:03

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

akiroz14:05:21

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?

favila14:05:55

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

akiroz14:05:23

gotcha, thanks! 🙂

akiroz14:05:00

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.

favila14:05:19

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