{"record":{"id":"23eb12473a8c332b","repo":"apache/cassandra","slug":"the-local-data-center-must-be-part-of-the-repair","errorCode":null,"errorMessage":"the local data center must be part of the repair; requested {options.getDataCenters()} but DC is {DatabaseDescriptor.getLocalDataCenter()}","messagePattern":"the local data center must be part of the repair; requested (.+?) but DC is (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":3222,"sourceCode":"        for (int i = start; i != end; i = (i+1) % tokens.size())\n        {\n            Range<Token> range = new Range<>(tokens.get(i), tokens.get((i+1) % tokens.size()));\n            repairingRange.add(range);\n        }\n\n        return repairingRange;\n    }\n\n    public TokenFactory getTokenFactory()\n    {\n        return ClusterMetadata.current().partitioner.getTokenFactory();\n    }\n\n    private FutureTask<Object> createRepairTask(final int cmd, final String keyspace, final RepairOption options, List<ProgressListener> listeners)\n    {\n        if (!options.getDataCenters().isEmpty() && !options.getDataCenters().contains(DatabaseDescriptor.getLocalDataCenter()))\n        {\n            throw new IllegalArgumentException(\"the local data center must be part of the repair; requested \" + options.getDataCenters() + \" but DC is \" + DatabaseDescriptor.getLocalDataCenter());\n        }\n        Set<String> existingDatacenters = ClusterMetadata.current().directory.allDatacenterEndpoints().keys().elementSet();\n        List<String> datacenters = new ArrayList<>(options.getDataCenters());\n        if (!existingDatacenters.containsAll(datacenters))\n        {\n            datacenters.removeAll(existingDatacenters);\n            throw new IllegalArgumentException(\"data center(s) \" + datacenters.toString() + \" not found\");\n        }\n\n        RepairCoordinator task = new RepairCoordinator(this, cmd, options, keyspace);\n        task.addProgressListener(progressSupport);\n        for (ProgressListener listener : listeners)\n            task.addProgressListener(listener);\n\n        if (options.isTraced())\n            return new FutureTaskWithResources<>(() -> ExecutorLocals::clear, task);\n        return new FutureTask<>(task);\n    }","sourceCodeStart":3204,"sourceCodeEnd":3240,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L3204-L3240","documentation":"createRepairTask validates that when a repair explicitly lists datacenters (-dc), the local node's datacenter must be among them; otherwise this node cannot coordinate a meaningful repair. Thrown as IllegalArgumentException before the RepairCoordinator is created.","triggerScenarios":"Calling `nodetool repair -dc dc1 <keyspace>` from a node whose DatabaseDescriptor.getLocalDataCenter() is, say, dc2 — i.e., the requested DC set does not include the coordinator's own DC.","commonSituations":"Multi-DC clusters where an operator SSHes into the wrong DC's node; endpoint_snitch misconfiguration so the node's local DC differs from expectation; copy-pasted repair commands between DCs.","solutions":["Run the repair from a node in one of the requested datacenters, or add the local DC to -dc","Verify the node's DC via nodetool info / gossip and correct endpoint_snitch or cassandra-rackdc.properties if the local DC is wrong","Include all target DCs, e.g. -dc dc1,dc2"],"exampleFix":"// before\nnodetool repair -dc dc1 my_keyspace   # run on a dc2 node\n// after\nnodetool repair -dc dc1,dc2 my_keyspace","handlingStrategy":"validation","validationCode":"String localDc = DatabaseDescriptor.getLocalDataCenter();\nif (!options.getDataCenters().isEmpty() && !options.getDataCenters().contains(localDc))\n    options.getDataCenters().add(localDc);","typeGuard":null,"tryCatchPattern":"try { ss.repairAsync(ks, opt); } catch (IllegalArgumentException e) { /* rerun from a node in the requested DC or include local DC */ }","preventionTips":["Verify each node's DC with nodetool info before launching repairs","Always include the coordinator's DC in -dc lists","Keep endpoint_snitch and cassandra-rackdc.properties consistent across DCs"],"tags":["cassandra","repair","datacenter","configuration"],"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-14T16:17:12.679Z"}