{"record":{"id":"97721e536b867476","repo":"apache/cassandra","slug":"concurrent-reads-must-be-non-negative","errorCode":null,"errorMessage":"Concurrent reads must be non-negative","messagePattern":"Concurrent reads must be non-negative","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":2925,"sourceCode":"    {\n        return conf.phi_convict_threshold;\n    }\n\n    public static void setPhiConvictThreshold(double phiConvictThreshold)\n    {\n        conf.phi_convict_threshold = phiConvictThreshold;\n    }\n\n    public static int getConcurrentReaders()\n    {\n        return conf.concurrent_reads;\n    }\n\n    public static void setConcurrentReaders(int concurrent_reads)\n    {\n        if (concurrent_reads < 0)\n        {\n            throw new IllegalArgumentException(\"Concurrent reads must be non-negative\");\n        }\n        conf.concurrent_reads = concurrent_reads;\n    }\n\n    public static int getConcurrentWriters()\n    {\n        return conf.concurrent_writes;\n    }\n\n    public static void setConcurrentWriters(int concurrent_writers)\n    {\n        if (concurrent_writers < 0)\n        {\n            throw new IllegalArgumentException(\"Concurrent reads must be non-negative\");\n        }\n        conf.concurrent_writes = concurrent_writers;\n    }\n","sourceCodeStart":2907,"sourceCodeEnd":2943,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L2907-L2943","documentation":"IllegalArgumentException from setConcurrentReaders: the setter guard rejects a negative value for concurrent_reads. Unlike most yaml-parsed settings this fires on programmatic/runtime updates (e.g. via tooling) since the plain setter has no parsing step; the value must be 0 or a positive thread count.","triggerScenarios":"Calling DatabaseDescriptor.setConcurrentReaders(-1) or lower directly, or via JMX/dynamic config with a negative value.","commonSituations":"JMX scripts computing a value (e.g. multiplier) producing negative result; config typo '-1' intending 'unlimited'.","solutions":["Pass a non-negative integer (0 allowed; typical values 16-64)","Fix the config key concurrent_reads in cassandra.yaml if it is negative"],"exampleFix":"// before\nDatabaseDescriptor.setConcurrentReaders(-1);\n// after\nDatabaseDescriptor.setConcurrentReaders(32);","handlingStrategy":"validation","validationCode":"if (concurrentReaders < 0)\n    throw new IllegalArgumentException(\"concurrent_reads must be >= 0, got \" + concurrentReaders);","typeGuard":null,"tryCatchPattern":"try { DatabaseDescriptor.setConcurrentReaders(v); }\ncatch (IllegalArgumentException e) { logger.error(\"Invalid concurrent_reads: {}\", e.getMessage()); }","preventionTips":["Math.max(0, value) before calling the setter","Don't use negative values to mean 'unlimited' — 0 or a positive number is required","Validate computed tuning values before applying"],"tags":["config","threads","validation"],"backgroundTag":"value-out-of-range","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"}