Mandroid
Mandroid

Reputation: 7524

A query on Cassandra data replication

I understand that when we write data in Cassandra, partition key is hashed by a partitioner and that value is then used to determine which node in the cluster that data would be stored into. And then Cassandra replicates that data in clockwise direction in the nodes ring.

If the node determined by partitioner is down then how does Cassandra find which nodes to look into for a record? Don't we lose the advantage of partitioning here?

Upvotes: 1

Views: 113

Answers (2)

Alex Ott
Alex Ott

Reputation: 87349

Hash that is calculated based on the value of partition key is identifying all replicas that are owning the data (if you use RF > 1). This is used by driver (when using token-aware load balancing policy) or by coordinating node to send a request to one of the replicas that are available, so you can continue to receive data (of course, if you have enough nodes to meet specified consistency level).

Upvotes: 2

Saifallah KETBI
Saifallah KETBI

Reputation: 313

if the node is down the data can be sent to the replica, depending on your replication factor and of your consistency level, your request might fail, if the number of acknowledgment required are not met. Of course, depending on your replication factor and CL, read request will be served or not. depending on how many replicas you have and how many acknowledgment you expect.

There is a cool mechanism used to help this kind of cases, it is hinted handoff. To make it simple if you have replication factor set to 1, and the node responsible of the data is down, the coordinator will store the data for him for a while ( hours) then when the node will be up again the coordinator will send him the missed data.

To make it more simple, it is like a neighbor taking your mail while your not around. This is made for small failure failures and not long one. it won't be cool if the neighbor will take the post mail for years.

Here is a link that explain how hints work

https://www.datastax.com/blog/2011/05/understanding-hinted-handoff-cassandra-08

I hope this help !

Upvotes: 1

Related Questions