Causal Consistency
I was attending to a neo4j meetup today. I learned a lot about distributed systems. First of all, I understood what the eventual consistency is. I thought, I had a little idea about it (honestly, I have never read anything about it specifically), but it turned out that it is a totally different thing. :)
Brief explanation of Eventual Consistency: In a distributed world to keep your data consistent you have to distribute all the transactions from a node to all of the others. In the meanwhile, the committed transactions are distributing, it can occur that a request comes which expect the presence of a transaction which hasn’t been distributed yet to the node which serves the request and the response will show an inconsistent state. But, this inconsistent state disappears immediately when the transactions arrive from the other nodes. So, eventually consistent the system.
Real description of eventual consistency here.
And here we are. We arrived to the main topic of the meetup. Frankly, the eventual consistency was new to me and then they explained their causal consistency implementation and my mind was blowing up.
Brief explanation of Causal Consistency: The Causal Consistency differ from the Eventual Consistency where the request arrives to a node and the request expects a transaction (so it depends on a previous transaction) which is not there. You can avoid this situation with a very little, smart trick. Use bookmarks. The expected transaction is a write transaction which returns a transaction id or bookmark and that bookmarks is used in the next request. With this bookmark the node check the transaction history and if the node is behind the bookmark then it waits until the right transaction is distributed. If the transaction history is ahead of the bookmark then the node immediately executes the transaction.
Real description of causal consistency here.
I have to mention, that the neo4j team implemented the Raft protocol to achieve the causal consistency. This protocol makes sure that if the majority of the nodes are copied, accepted the transaction then the user get the acknowledgement about it and the protocol force the other nodes to accept the transaction in the right order.
So I learned a lot and the neo4j guys are awesome and nice.
Please, consider all the descriptions as a naive explanation. Right now, I don’t know much about these topics, so please read the citations. These descriptions reflects how these things are in my mind, not a exhausted description or even not precise.
















