0

I am doing a project with riak database and I am accessing it from an erlang application. I know that erlang escapes race conditions on resources by allowing data to be immutable and no data sharing between processes. In my application, I will be doing a lot of read, update and store operations. This will lead to inconsistent objects in my database if performed by concurrent processes with different update data.

Is there anyway to synchronize these operations between concurrent processes? I don't want object siblings to exist in the riak bucket.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Given your requirements it sounds like you should consider [Riak's strong consistency support](http://docs.basho.com/riak/latest/dev/advanced/strong-consistency/). – Steve Vinoski Feb 22 '16 at 12:55
  • It was helpful a bit. let me me clear it. Imagine two processes A and B. Both reads a value concurrently which is a map M = #{a => 1, b=> 2}. A update the map to AM = #{a = > 2, b=> 1} and B to BM = #{a => 1, b => 3}. Assume by preemption, process B write the updated map before A. After the final write by process A, the stored value will be seen as #{a => 2, b => 1} instead of #{a = > 2, b=> 3}. This is the problem I am escaping. –  Feb 22 '16 at 13:55
  • isn't that map issue solved by the map data type: http://docs.basho.com/riak/latest/dev/using/data-types/#Maps – Joe Feb 23 '16 at 21:08
  • I don't think there is a ready solution, buit conceptually you want _counter in a set_ [CRDT](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type#CRDT_classes) – Lol4t0 Feb 24 '16 at 18:28

0 Answers0