2

From my limited knowledge, Cassandra assigns a random token for every new node in the ring. The ring position is important because data is replicated in the SimpleStrategy according to the position. So what happens when the node restarts and wants to join the ring again, will it be assigned a new token? If that's the case then all the data in that node needs to be sent to their correct place every time it restarts.

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23

1 Answers1

1

Cassandra nodes only get assigned a token when they join a cluster for the very first time.

When a node has bootstrapped successfully, it's allocated token is stored in the system.local table so it knows which token range(s) it owns when it is restarted. All the nodes also keep track of each other's token assignments in memory and are propagated via gossip (see nodetool gossipinfo).

Note that the same applies for nodes with multiple tokens (virtual nodes configuration). Cheers!

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
  • Thanks for the answer, I had another question, while assigning a random token if that token identifier conflicts with another token in the ring, how does Cassandra detect that collision and fix that? – Mainul Islam Mahi Jul 03 '22 at 08:14
  • That's a completely different question to the one you originally asked. If we keep responding to follow up questions in the comments section, it becomes a never-ending thread so please log a separate question. Cheers! – Erick Ramirez Jul 03 '22 at 11:32