Search code examples
cassandradatastaxdatastax-enterprisecassandra-2.0bigdata

In 2 node cassandra cluster if RF=1 and one node is down, I can write with CL=1 but can't read


I am new to cassandra.

I have a cluster which contains two nodes. I have set Replication factor as 1. Now if one node goes down, I can insert the data with no errors with Consistency = ONE. After insert, if I try to tad the same then it gives me an error

Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level ONE" info={'required_replicas': 1, 'alive_replicas': 0, 'consistency': 'ONE'}

Why didn't cassandra read data from coordinator node ? If one node is UP then alive_replicas should be 1, isn't it ?

I am using cqlsh client.


Solution

  • Replication factor of 1 means that every data exists only once (it is not the number of additional copies, but the number of total copies). Having a cluster with two nodes and RF=1, roughly 50% of your data will be on node1, and the other half will reside on the node2.

    You can verify this with the command (check the percentages under the Owns column)

    nodetool status your_keyspace_name
    

    Now, if one of your nodes is down, then only those keys are accessible that are stored on the live node. This applies for both read and write. Thus the operations affecting the live node will succeed while the ones affecting the dead node will fail. You can check which node is responsible for any given partition key with the command

    nodetool getendpoints your_keyspace your_table your_key
    

    So to answer your question, I suppose that the successful write affected the live node, while the failing read affected the node which was down.