{"record":{"id":"e0fb2f47445b5910","repo":"apache/cassandra","slug":"specified-hosts-s-do-not-share-range-s-needed-fo","errorCode":null,"errorMessage":"Specified hosts %s do not share range %s needed for repair. Either restrict repair ranges with -st/-et options, or specify one of the neighbors that share this range with this node: %s.","messagePattern":"Specified hosts (.+?) do not share range (.+?) needed for repair\\. Either restrict repair ranges with -st/-et options, or specify one of the neighbors that share this range with this node: (.+?)\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/ActiveRepairService.java","lineNumber":656,"sourceCode":"                    final InetAddressAndPort endpoint = InetAddressAndPort.getByName(host.trim());\n                    if (endpoint.equals(ctx.broadcastAddressAndPort()) || neighbors.endpoints().contains(endpoint))\n                        specifiedHost.add(endpoint);\n                }\n                catch (UnknownHostException e)\n                {\n                    throw new IllegalArgumentException(\"Unknown host specified \" + host, e);\n                }\n            }\n\n            if (!specifiedHost.contains(ctx.broadcastAddressAndPort()))\n                throw new IllegalArgumentException(\"The current host must be part of the repair\");\n\n            if (specifiedHost.size() <= 1)\n            {\n                String msg = \"Specified hosts %s do not share range %s needed for repair. Either restrict repair ranges \" +\n                             \"with -st/-et options, or specify one of the neighbors that share this range with \" +\n                             \"this node: %s.\";\n                throw new IllegalArgumentException(String.format(msg, hosts, toRepair, neighbors));\n            }\n\n            specifiedHost.remove(ctx.broadcastAddressAndPort());\n            return neighbors.keep(specifiedHost);\n        }\n\n        return neighbors;\n    }\n\n    /**\n     * we only want to set repairedAt for incremental repairs including all replicas for a token range. For non-global\n     * incremental repairs, forced incremental repairs, and full repairs, the UNREPAIRED_SSTABLE value will prevent\n     * sstables from being promoted to repaired or preserve the repairedAt/pendingRepair values, respectively.\n     */\n    long getRepairedAt(RepairOption options, boolean force)\n    {\n        // we only want to set repairedAt for incremental repairs including all replicas for a token range. For non-global incremental repairs, full repairs, the UNREPAIRED_SSTABLE value will prevent\n        // sstables from being promoted to repaired or preserve the repairedAt/pendingRepair values, respectively. For forced repairs, repairedAt time is only set to UNREPAIRED_SSTABLE if we actually","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/ActiveRepairService.java#L638-L674","documentation":"After filtering the -hosts list to nodes that share the repair range, if only the local node (or fewer than 2 hosts) remains, no neighbor exists to repair against. Cassandra throws this IllegalArgumentException explaining that the specified hosts do not share the range and suggesting restricting ranges or picking real neighbors.","triggerScenarios":"Specifying -hosts where none of the other hosts is a replica (neighbor) for the token range being repaired, e.g. listing nodes from a different datacenter/rack that don't hold the range, or listing only the local node plus non-replica nodes.","commonSituations":"Operators picking hosts manually for a sub-range repair without checking ring ownership (nodetool ring/describering); topology changes moved range ownership since the host list was written.","solutions":["Run nodetool describering/ring to find which nodes share the target range and list those in -hosts","Restrict the repair with -st/-et so the range matches the ranges the specified hosts share","Drop the -hosts option entirely to let Cassandra pick the correct neighbors"],"exampleFix":"// before\nnodetool repair keyspace1 -st A -et B -hosts node1,node7  # node7 not a replica of [A,B]\n// after\nnodetool repair keyspace1 -st A -et B -hosts node1,node2  # node2 replica of [A,B]","handlingStrategy":"validation","validationCode":"// confirm at least one specified host is a peer replica for the range\nCollection<InetAddressAndPort> natural = storageService.getNaturalEndpoints(keyspace, rangeToken);\nboolean hasNeighbor = hosts.stream().anyMatch(h -> !h.equals(local) && natural.contains(h));","typeGuard":null,"tryCatchPattern":"try { repair(...); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Specified hosts\")) log.error(\"hosts don't share range; use describering\", e);\n    throw e;\n}","preventionTips":["Consult nodetool describering keyspace before choosing -hosts","Avoid hardcoding host lists in scripts; recompute after any topology change","Omit -hosts to let Cassandra select neighbors automatically"],"tags":["repair","topology","hosts"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}