Cassandra
  1. Cassandra
  2. CASSANDRA-3880

Random Partitioner does not check if tokens are outside of its range

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Not a Problem
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      Setting up a ring where the tokens are outside RP's token range leads to an unbalanced cluster. The partitioner still reports equally distributed ownership since it calculates ownership only with the distances of the tokens in relation to the maximum token.

      E.g. maximum token = 15
      token1 = 5
      token2 = 10
      token3 = 15
      token4 = 20

      ownership4 = (token4 - token3) / maximum_token = 5 / 15 = 1/3

      So token4 claims to own 33.33% of the ring but is not responsible for any primary replicas.

        Issue Links

          Activity

          Hide
          Harish Doddi added a comment -

          I would like to do this patch. If there are any issues, please let me know.

          Show
          Harish Doddi added a comment - I would like to do this patch. If there are any issues, please let me know.
          Hide
          Harish Doddi added a comment -

          Hi,

          I have seen from the code the RP's token range as of now is from 0 to 2^127

          There are checks in the code if you bring a node with a token > 2^127, you run into a configuration exception. As a result that node cannot be bootstrapped. I validated this by supplying a token > 2^127

          If you think there is something I am missing, please let me know.

          Show
          Harish Doddi added a comment - Hi, I have seen from the code the RP's token range as of now is from 0 to 2^127 There are checks in the code if you bring a node with a token > 2^127, you run into a configuration exception. As a result that node cannot be bootstrapped. I validated this by supplying a token > 2^127 If you think there is something I am missing, please let me know.
          Hide
          Brandon Williams added a comment -

          A token greater than 2^127 is invalid.

          Show
          Brandon Williams added a comment - A token greater than 2^127 is invalid.
          Hide
          Marcel Steinbach added a comment -

          Harish, you're right, there is code that checks if the token is within the partitioner's range. I checked the history - it was added with CASSANDRA-3501.
          In my case, the token range was set up with version 0.7.6 (without that patch). The patch only checks on moves/bootstraps, so it went undetected.

          So to reproduce the bug you would need to move a token outside the range with version < 1.0.4. Upgrading would not help recognizing the mistake.

          You could call validate(token) in describeOwnership to give a hint in nodetool. But I don't think it's really necessary since that's only legacy support...

          Show
          Marcel Steinbach added a comment - Harish, you're right, there is code that checks if the token is within the partitioner's range. I checked the history - it was added with CASSANDRA-3501 . In my case, the token range was set up with version 0.7.6 (without that patch). The patch only checks on moves/bootstraps, so it went undetected. So to reproduce the bug you would need to move a token outside the range with version < 1.0.4. Upgrading would not help recognizing the mistake. You could call validate(token) in describeOwnership to give a hint in nodetool. But I don't think it's really necessary since that's only legacy support...
          Hide
          Jonathan Ellis added a comment -

          Resolving NotAProblem since modern versions do check per Marcel's investigation.

          Show
          Jonathan Ellis added a comment - Resolving NotAProblem since modern versions do check per Marcel's investigation.

            People

            • Assignee:
              Unassigned
              Reporter:
              Marcel Steinbach
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development