Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-11139

New token allocator is broken

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 3.0.4, 3.4
    • Component/s: Local/Config
    • Labels:
      None

      Description

      It looks like the logic in the if statment in TokenAllocation.getStrategy() is broken.

      if (replicas >= racks)
      {...}
      else if (racks == 1)
      {...}
      else
          throw new ConfigurationException(String.format("Token allocation failed: the number of racks %d in datacenter %s is lower than its replication factor %d.", racks, dc, replicas));
      

      I think the first if statment should be (replicas <= racks), otherwise this will be true if we have fewer racks then replicas and I guess that should result in an exception.

      Also the if and the else if blocks should change place, it should be

      if (racks == 1)
      {...}
      else if (replicas <= racks)
      {...}
      else
      

      If replicas==1 and racks==1 I think you want the StrategyAdapter from (racks==1).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                blambov Branimir Lambov
                Reporter:
                tommy_s Tommy Stendahl
                Authors:
                Branimir Lambov
                Reviewers:
                Tom Hobbs
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: