2

I am wondering about the Atomicity semantics in Chronicle Map. If I have a chronicle map shared across 2 nodes (servers) and I try to insert the same key into this map simultaneously on both nodes, what are the transactional semantics?

Will the first put succeed and the second fail?

I am curious if Chronicle Map guarantees the same Transactional semantics as, Apache Zookeeper?

In my usecase, I would like to rely on the fact, that if node1 puts a key K1 into the map, that node2 would be able to check for the existence of K1 and if it's not there it would know definitively that it's the first to add K1.

Effectively, asking if a put on ChronicleMap is a distributed transaction, which spans across the 2 nodes.

Many thanks Clifford

leventov
  • 14,760
  • 11
  • 69
  • 98
cliff
  • 43
  • 1
  • 3

1 Answers1

1

Chronicle Map uses eventual consistency and the last one wins. When you look at micro second time scales, nodes are in a split brain node as there is no way to keep them in sync at this speed. This is by design as Map is designed to support millions of updates per second per server. In general, it is not hard to ensure two servers don't update the same key at the same time under normal operation. E.g. you can pass all updates to one server using Engine or you can partition the keys for update. While distributed transactions sound like a great idea, you should note that; - they are many orders of magnitude slower, - very hard to recover from when you have failure like split brain. - testing your application works correctly across different failure conditions is a real pain.

My view us it is better to design a system which doesn't need this assumption and you will know how it behaves on failure without extensive testing.

Say you install zookeeper to three data centres and ensure the failure of one data centre doesn't stop operation by ensuring no data centre has half the nodes or more (two data centres is not enough) however say you have temporary split brain caused by a slow interconnect, this impacts any updates but in a transient in a hard to reproduce or test way. With chronicle map, the data centres can be disconnected for any amount of time and all its guarantees are honoured and you have no additional testing to do. In fact you can lose all but one node and still have full operation.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    Thanks for the detailed response Peter. I have orders which can be routed to any of 3 outgoing gateways, for ultimate delivery to an ECN (this is to ensure high availability). I am trying to guarantee that the first gateway to receive an order is the one which sends this on to the exchange and the other 2 should never. I was going to add the unique order id to Chronicle and have all 3 gateways check for the existence of this order id before sending through an order. Based on your recommendations above, do you have any suggestions on how to achieve this? is Chronicle Map a good fit? – cliff Sep 29 '17 at 12:52