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.
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!