{"record":{"id":"f880c8d44b0229dd","repo":"apache/cassandra","slug":"use-the-d-flag-to-quiet-this-error-and-get-the-ex","errorCode":null,"errorMessage":"Use the -d flag to quiet this error and get the exact throughput in MiB/s","messagePattern":"Use the -d flag to quiet this error and get the exact throughput in MiB/s","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/tools/nodetool/GetCompactionThroughput.java","lineNumber":45,"sourceCode":"import picocli.CommandLine.Option;\n\n@Command(name = \"getcompactionthroughput\", description = \"Print the MiB/s throughput cap for compaction in the system as a rounded number\")\npublic class GetCompactionThroughput extends AbstractCommand\n{\n    @Option(names = { \"-d\", \"--precise-mib\" }, description = \"Print the MiB/s throughput cap for compaction in the system as a precise number (double)\")\n    private boolean  compactionThroughputAsDouble;\n\n    @Override\n    public void execute(NodeProbe probe)\n    {\n        double throughput = probe.getCompactionThroughputMebibytesAsDouble();\n\n        if (compactionThroughputAsDouble)\n            probe.output().out.println(\"Current compaction throughput: \" + throughput + \" MiB/s\");\n        else\n        {\n            if (!DoubleMath.isMathematicalInteger(throughput))\n                throw new RuntimeException(\"Use the -d flag to quiet this error and get the exact throughput in MiB/s\");\n\n            probe.output().out.println(\"Current compaction throughput: \" + probe.getCompactionThroughput() + \" MiB/s\");\n        }\n\n        Map<String, String> currentCompactionThroughputMetricsMap = probe.getCurrentCompactionThroughputMiBPerSec();\n        probe.output().out.println(\"Current compaction throughput (1 minute): \" + currentCompactionThroughputMetricsMap.get(\"1minute\") + \" MiB/s\");\n        probe.output().out.println(\"Current compaction throughput (5 minute): \" + currentCompactionThroughputMetricsMap.get(\"5minute\") + \" MiB/s\");\n        probe.output().out.println(\"Current compaction throughput (15 minute): \" + currentCompactionThroughputMetricsMap.get(\"15minute\") + \" MiB/s\");\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/GetCompactionThroughput.java#L27-L56","documentation":"GetCompactionThroughput prints the throughput as an integer when -d is absent; if the configured compaction throughput is a non-integer MiB/s value, it throws this RuntimeException telling the operator to use -d. It protects against silently rounding the value.","triggerScenarios":"Running `nodetool getcompactionthroughput` when compaction_throughput_mb_per_sec in cassandra.yaml is set to a fractional value (e.g. 63.5) without the -d flag.","commonSituations":"Operators set fractional throughput values for tuning; monitoring scripts parse output and break on the thrown error; versions where the setting became a double.","solutions":["Run `nodetool getcompactionthroughput -d` to print the exact double value","Set compaction_throughput_mb_per_sec to an integer in cassandra.yaml","Update monitoring scripts to pass -d and parse a double"],"exampleFix":"// before\nnodetool getcompactionthroughput\n// after\nnodetool getcompactionthroughput -d","handlingStrategy":"validation","validationCode":"// pass -d whenever fractional values are possible\nnodetool getcompactionthroughput -d","typeGuard":null,"tryCatchPattern":"try { probe.execute(); } catch (RuntimeException e) { if (e.getMessage().contains(\"-d flag\")) retryWithDoubleFlag(); }","preventionTips":["Always use -d in automation","Keep compaction_throughput_mb_per_sec an integer if scripts rely on integer output","Parse output as double"],"tags":["nodetool","cli","throughput"],"backgroundTag":"invalid-flag-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"}