I have 3 virtual Cassandra nodes cluster. Node1, Node2 & Node3.

I have written a small python code to bulk load data into it.

1st time only 2 nodes out of three are available online, Node1 & Node2 when I execute the python code with

session.default_consistency_level = 2

I got and error:

cassandra.Unavailable: Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level TWO" info={'consistency': 'TWO', 'required_replicas': 2, 'alive_replicas': 1}

After that I brought my third node (Node3) online and executed the python program, it executed successfully.

As I understand Consistency Level = 2 means at least 2 nodes out of 3 should be available every time.



Consistency level refers to the number of replicas required, but the number of total replicas that exists is independent of the number of nodes. It is set by your Replication_Strategy. If your strategy for this keyspace only has 2 replicas then there are many situations where a CL of 2 would fail.

For nodes A, B and C

Imagine the data you want has been replicated to A and B.

But only A and C are alive. You can only get one replica even though 2 nodes are alive.

  • How Cassandra decides that Record1 should be replicated to Node B from Node ,A not to Node C? Nov 9 '17 at 17:46
  • By the token value, the hash of the partition key. Given a topology and replication strategy, a values placement and replication is deterministic
    – RussS
    Nov 9 '17 at 17:56
  • When we configure nodes, we assign separate token value to each nodes. Assume if token value of Recored1 is x01 for Node A, how it will satisfy token value of Node B? As I understand records may be replicated to any available nodes (>= replication strategy). Nov 9 '17 at 18:10
  • 1
    It will not be replicated to any available nodes. It will be replicated to a specific node. The last I check the algorithm was, primary token range + next (n) nodes in ring order. So in the 3 node example you would only get replicas like A B, B C, C A But it's been a while and that may have changed.
    – RussS
    Nov 9 '17 at 18:13
  • 1
    If it was the next available node, how would you ever find replicas? It would be random based on when the value was inserted?
    – RussS
    Nov 9 '17 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.