{"record":{"id":"774b3d0427ba07aa","repo":"apache/cassandra","slug":"can-t-have-both-fixed-and-throttle-set-choose-one","errorCode":null,"errorMessage":"can't have both fixed and throttle set, choose one.","messagePattern":"can't have both fixed and throttle set, choose one\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/SettingsRate.java","lineNumber":50,"sourceCode":"{\n\n    public final boolean auto;\n    public final int minThreads;\n    public final int maxThreads;\n    public final int threadCount;\n    public final int opsPerSecond;\n    public final boolean isFixed;\n\n    public SettingsRate(ThreadOptions options)\n    {\n        auto = false;\n        threadCount = Integer.parseInt(options.threads.value());\n        String throttleOpt = options.throttle.value();\n        String fixedOpt = options.fixed.value();\n        int throttle = Integer.parseInt(throttleOpt.substring(0, throttleOpt.length() - 2));\n        int fixed = Integer.parseInt(fixedOpt.substring(0, fixedOpt.length() - 2));\n        if(throttle != 0 && fixed != 0)\n            throw new IllegalArgumentException(\"can't have both fixed and throttle set, choose one.\");\n        opsPerSecond = Math.max(fixed, throttle);\n        isFixed = (opsPerSecond == fixed);\n\n        minThreads = -1;\n        maxThreads = -1;\n    }\n\n    public SettingsRate(AutoOptions auto)\n    {\n        this.auto = auto.auto.setByUser();\n        this.minThreads = Integer.parseInt(auto.minThreads.value());\n        this.maxThreads = Integer.parseInt(auto.maxThreads.value());\n        this.threadCount = -1;\n        this.opsPerSecond = 0;\n        isFixed = false;\n    }\n\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/SettingsRate.java#L32-L68","documentation":"SettingsRate lets you limit throughput either with -rate throttle=<N>/s (dynamic rate limiting) or -rate fixed=<N>/s (fixed rate), but not both. The constructor throws IllegalArgumentException when both parse to non-zero values because the two modes are mutually exclusive.","triggerScenarios":"cassandra-stress ... -rate threads=10 throttle=5000/s fixed=3000/s — both throttle and fixed options supplied with non-zero values.","commonSituations":"Merging rate settings from two script fragments, or a template command that already contains fixed= while the operator appends throttle=.","solutions":["Keep only one of throttle= or fixed= in the -rate option","If you want a strict fixed rate, drop throttle=; if you want adaptive throttling, drop fixed=","threads= can be combined with either one, so keep threads and one rate knob"],"exampleFix":"// before\n-rate threads=10 throttle=5000/s fixed=3000/s\n// after\n-rate threads=10 throttle=5000/s","handlingStrategy":"validation","validationCode":"boolean hasThrottle = cmdLine.matches(\".*-rate[^-]*throttle=[^0]\");\nboolean hasFixed = cmdLine.matches(\".*-rate[^-]*fixed=[^0]\");\nif (hasThrottle && hasFixed) throw new IllegalArgumentException(\"choose either throttle or fixed\");","typeGuard":null,"tryCatchPattern":"try { SettingsRate.get(clArgs, cmd); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"both fixed and throttle\")) stripOption(args, \"fixed\"); else throw e; }","preventionTips":["Pick one throughput knob per run: throttle OR fixed","When templating commands, strip rate fragments before appending new ones","Comment out rather than zero-out competing options in config templates"],"tags":["cli","config","mutually-exclusive"],"backgroundTag":"mutually-exclusive-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"}