{"record":{"id":"4d009adde0f3028c","repo":"apache/cassandra","slug":"primary-range-repair-should-be-performed-on-all-no","errorCode":null,"errorMessage":"Primary range repair should be performed on all nodes in the cluster.","messagePattern":"Primary range repair should be performed on all nodes in the cluster\\.","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/Repair.java","lineNumber":164,"sourceCode":"        {\n            return PreviewKind.UNREPAIRED;\n        }\n        else\n        {\n            return PreviewKind.NONE;\n        }\n    }\n\n    @Override\n    public void execute(NodeProbe probe)\n    {\n        args = concatArgs(keyspace, tables);\n\n        List<String> keyspaces = parseOptionalKeyspaceNonLocal(args, probe);\n        String[] cfnames = parseOptionalTables(args);\n\n        if (primaryRange && (!specificDataCenters.isEmpty() || !specificHosts.isEmpty()))\n            throw new RuntimeException(\"Primary range repair should be performed on all nodes in the cluster.\");\n\n        for (String keyspace : keyspaces)\n        {\n            // avoid repairing system_distributed by default (CASSANDRA-9621)\n            if ((args == null || args.isEmpty()) && ONLY_EXPLICITLY_REPAIRED.contains(keyspace))\n                continue;\n\n            Map<String, String> options = createOptions(probe::getDataCenter, cfnames);\n            try\n            {\n                probe.repairAsync(probe.output().out, keyspace, options);\n            } catch (Exception e)\n            {\n                throw new RuntimeException(\"Error occurred during repair\", e);\n            }\n        }\n    }\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/Repair.java#L146-L182","documentation":"Nodetool 'repair -pr' (primary-range) repairs only the ranges a node is primary for, so it is inherently node-local. Combining -pr with -dc (specificDataCenters) or -hosts (specificHosts) is contradictory and rejected with this RuntimeException before any repair starts.","triggerScenarios":"`nodetool repair -pr -dc dc1`, `nodetool repair -pr -hosts h1`, or `-pr` with any -dc/-hosts combination.","commonSituations":"Operators trying to scope a primary-range repair to one DC; mixing flags from examples of different repair modes.","solutions":["Drop -pr if you need DC/host scoping: `nodetool repair -dc dc1`","Drop the -dc/-hosts flags if you truly want the primary-range repair: `nodetool repair -pr`","Use -pr on each node individually instead of scoping flags"],"exampleFix":"// before\nnodetool repair -pr -dc dc1\n// after\nnodetool repair -dc dc1","handlingStrategy":"validation","validationCode":"FLAGS=\"-pr -dc dc1\"; [[ \"$FLAGS\" == *\"-pr\"* && ( \"$FLAGS\" == *\"-dc\"* || \"$FLAGS\" == *\"-hosts\"* ) ]] && { echo \"-pr cannot combine with -dc/-hosts\"; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine -pr with -dc or -hosts","Run -pr per-node when primary-range semantics are needed","Encode flag exclusivity in orchestration tooling"],"tags":["nodetool","repair","cli","conflicting-flags"],"backgroundTag":"conflicting-config-options","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"}