Initial Token is cassandra is not working as expected

纵饮孤独 提交于 2019-12-11 07:32:40

问题


To understand the ring without vNodes, I tried initial token in Node 1 as 25 and Node 2 as 50 like below,

Address       Rack        Status State   Load            Owns                Token                                       
                                                                             50                                          
172.30.56.60  rack1       Up     Normal  82.08 KiB       100.00%             25                                          
172.30.56.61  rack1       Up     Normal  82.09 KiB       100.00%             50  

I expect only the partition ranges between 0 to 50 should be added in database, But It is allowing any primary key / partition key value I provide as follows (user_id - primary / partition key).

 user_id    | user_name | user_phone
------------+-----------+------------
  999933333 |       ram | 9003934069
        111 |       ram | 9003934069
          1 |       ram | 9003934069
  111333333 |       ram | 9003934069
 1113333333 |       ram | 9003934069

where, user_id is the primary / partition key.

Does it mean that token provided in initial_token is the total number of tokens and not the partition range? If so how the partition range is calculated?

Thanks, Harry


回答1:


The token number is a hash of the partition key. This decides where the data should be stored.

(ref: https://www.datastax.com/dev/blog/repair-in-cassandra):

In this picture N0 is assigned token 0, N1 token 10 and so on. By doing this we say N1 is responsible for token ranges 1-10. However if we use RF 3 then we say N1 is responsible for token ranges 81-10 instead. What you have done in your example is saying 60 owns 51-25. Since there is still a total of 2^127 tokens (depending on your partitioner) that means it now owns a huge amount of data compared to 61.



来源:https://stackoverflow.com/questions/47628950/initial-token-is-cassandra-is-not-working-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!