{"record":{"id":"690d4937c9f87699","repo":"apache/beam","slug":"tokens-s-s-not-in-range-of-s","errorCode":null,"errorMessage":"Tokens (%s,%s) not in range of %s","messagePattern":"Tokens \\((.+?),(.+?)\\) not in range of (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/SplitGenerator.java","lineNumber":88,"sourceCode":"   * Each split can contain several token ranges in order to reduce the overhead of vnodes.\n   * Currently, token range grouping is not smart and doesn't check if they share the same replicas.\n   * This is planned to change once Beam is able to handle collocation with the Cassandra nodes.\n   *\n   * @param totalSplitCount requested total amount of splits. This function may generate more\n   *     splits.\n   * @param ringTokens list of all start tokens in big0 cluster. They have to be in ring order.\n   * @return big0 list containing at least {@code totalSplitCount} splits.\n   */\n  List<List<RingRange>> generateSplits(long totalSplitCount, List<BigInteger> ringTokens) {\n    int tokenRangeCount = ringTokens.size();\n\n    List<RingRange> splits = new ArrayList<>();\n    for (int i = 0; i < tokenRangeCount; i++) {\n      BigInteger start = ringTokens.get(i);\n      BigInteger stop = ringTokens.get((i + 1) % tokenRangeCount);\n\n      if (!isInRange(start) || !isInRange(stop)) {\n        throw new RuntimeException(\n            String.format(\"Tokens (%s,%s) not in range of %s\", start, stop, partitioner));\n      }\n      if (start.equals(stop) && tokenRangeCount != 1) {\n        throw new RuntimeException(\n            String.format(\"Tokens (%s,%s): two nodes have the same token\", start, stop));\n      }\n\n      BigInteger rs = stop.subtract(start);\n      if (rs.compareTo(BigInteger.ZERO) <= 0) {\n        // wrap around case\n        rs = rs.add(rangeSize);\n      }\n\n      // the below, in essence, does this:\n      // splitCount = ceiling((rangeSize / RANGE_SIZE) * totalSplitCount)\n      BigInteger[] splitCountAndRemainder =\n          rs.multiply(BigInteger.valueOf(totalSplitCount)).divideAndRemainder(rangeSize);\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/SplitGenerator.java#L70-L106","documentation":"During split generation, SplitGenerator.generateSplits() validates that every ring token returned by Cassandra falls within the token space of the configured partitioner. If a start/stop token pair is outside the range, a RuntimeException is thrown, meaning ring metadata and partitioner are inconsistent.","triggerScenarios":"Calling CassandraIO read when the token ranges fetched from the cluster's ring contain tokens outside [rangeMin, rangeMax] of the detected partitioner (getRingRanges -> generateSplits).","commonSituations":"Cluster partitioner changed without a full rebuild; mixed-version or partially migrated ring; driver returning ring info from a different cluster than expected.","solutions":["Verify all nodes use the same partitioner and that it matches what the connector detected.","Run a full repair/rebuild after any partitioner change; a partitioner can never be changed in-place.","Check for multi-datacenter or multi-cluster misconfiguration in connection settings.","Inspect ring consistency with nodetool ring."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate ring consistency before read\nnodetool ring  // ensure tokens within partitioner range and consistent across nodes","typeGuard":null,"tryCatchPattern":"try { ... } catch (RuntimeException e) { if (e.getMessage().contains(\"not in range\")) { /* audit ring + partitioner */ } throw e; }","preventionTips":["Never change partitioner without rebuilding the cluster.","Run nodetool ring checks in pre-deploy validation.","Keep cluster versions and configurations uniform."],"tags":["java","cassandra","token-ring","inconsistent-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}