{"record":{"id":"71d931b485589c9a","repo":"apache/cassandra","slug":"number-of-concurrent-compactors-should-be-greater","errorCode":null,"errorMessage":"Number of concurrent compactors should be greater than 0.","messagePattern":"Number of concurrent compactors should be greater than 0\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":1508,"sourceCode":"    {\n        return DatabaseDescriptor.getBatchlogReplayThrottleInKiB();\n    }\n\n    public void setBatchlogReplayThrottleInKB(int throttleInKB)\n    {\n        DatabaseDescriptor.setBatchlogReplayThrottleInKiB(throttleInKB);\n        BatchlogManager.instance.setRate(throttleInKB);\n    }\n\n    public int getConcurrentCompactors()\n    {\n        return DatabaseDescriptor.getConcurrentCompactors();\n    }\n\n    public void setConcurrentCompactors(int value)\n    {\n        if (value <= 0)\n            throw new IllegalArgumentException(\"Number of concurrent compactors should be greater than 0.\");\n        DatabaseDescriptor.setConcurrentCompactors(value);\n        CompactionManager.instance.setConcurrentCompactors(value);\n    }\n\n    public void bypassConcurrentValidatorsLimit()\n    {\n        logger.info(\"Enabling the ability to set concurrent validations to an unlimited value\");\n        DatabaseDescriptor.allowUnlimitedConcurrentValidations = true ;\n    }\n\n    public void enforceConcurrentValidatorsLimit()\n    {\n        logger.info(\"Disabling the ability to set concurrent validations to an unlimited value\");\n        DatabaseDescriptor.allowUnlimitedConcurrentValidations = false ;\n    }\n\n    public boolean isConcurrentValidatorsLimitEnforced()\n    {","sourceCodeStart":1490,"sourceCodeEnd":1526,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L1490-L1526","documentation":"Thrown by StorageService.setConcurrentCompactors when a JMX or configuration caller attempts to set the number of concurrent compaction threads to zero or a negative value. Cassandra requires at least one compactor thread to make progress on compaction work, so non-positive values are rejected before updating DatabaseDescriptor and CompactionManager.","triggerScenarios":"Calling StorageService.setConcurrentCompactors(value) via JMX (mx4j/JConsole) or programmatically with value <= 0; setting concurrent_compactors in cassandra.yaml to 0 or a negative number and applying it at runtime.","commonSituations":"Operators mis-editing cassandra.yaml and setting concurrent_compactors: 0 thinking it disables compaction; automation scripts computing the value as a fraction of CPU cores that round down to 0 on small containers (e.g. 0.5 CPU cgroup limits); passing an uninitialized/absent config variable.","solutions":["Pass a positive integer, e.g. setConcurrentCompactors(2) or set concurrent_compactors to at least 1 in cassandra.yaml","If compaction should be paused, use nodetool disableautocompaction instead of setting compactors to 0","Verify the runtime environment exposes at least 1 CPU so core-count-derived defaults are >= 1"],"exampleFix":"// before\nstorageService.setConcurrentCompactors(0); // IllegalArgumentException\n// after\nint compactors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);\nstorageService.setConcurrentCompactors(compactors);","handlingStrategy":"validation","validationCode":"if (value <= 0) throw new IllegalArgumentException(\"concurrentCompactors must be >= 1, got \" + value);\nstorageService.setConcurrentCompactors(value);","typeGuard":"boolean isValidCompactorCount(int v) { return v > 0; }","tryCatchPattern":"try { storageService.setConcurrentCompactors(value); } catch (IllegalArgumentException e) { logger.warn(\"Invalid concurrent_compactors: {}\", value, e); }","preventionTips":["Clamp computed thread counts with Math.max(1, ...)","Never use 0 to mean 'disable compaction'; use nodetool disableautocompaction","Validate cassandra.yaml values before applying at runtime via JMX"],"tags":["configuration","jmx","compaction","validation"],"backgroundTag":"invalid-config-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"}