cassandranosqldatastaxeventual-consistency

Impact of DC in Cassandra Cluster for Consistency ONE


I am learning Cassandra architecture & have set-up a Cassandra cluster in virtual machine like below:

Node_1 -> DC_1 -> Rack1 -> rf = 1
Node_2 and Node_3 -> DC_2 -> Rack1 -> rf = 1

For Consistency Level ONE :

  1. When Node_1 and Node_3 are down, select query fails on Node_2 (Warning from Cassandra console : Consistency One cannot be set; Error from cqlsh : NoHostAvailable)
  2. When Node_1 and Node_2 are down, select query fails on Node_3 (Warning from Cassandra console : Consistency One cannot be set; Error from cqlsh : NoHostAvailable)
  3. But When Node_2 and Node_3 are down, then select query passes on Node_1(Warning from Cassandra console : Consistency One cannot be set; Error from cqlsh : No Error, displays the table data)

Noticed same behaviour for write as well.

Does this behaviour have something to do with nodes being in same or different DCs? Please explain the reason for this mismatch.


Solution

  • NoHostAvailable comes up when replicas with the data are not up and cluster cannot respond the requested data. In your case you are writing one replica on each Datacenter (DC_1 and DC_2). So it might have happened that when you shut down following combo Node_1 (DC_1) and Node_2(DC_2) nodes or Node_1 (DC_1) and Node_3(DC_2) nodes, you are not getting all the requested data from the live nodes. In case of Node_1 up you are sure that all your data will be retrieved since DC_1 contains 1 replica of data always and Node_1 is the only node in this datacenter. Hence you get the requested data.