{"record":{"id":"a1fe0f38a2241e1f","repo":"apache/cassandra","slug":"concurrent-accord-operations-must-be-non-negative","errorCode":null,"errorMessage":"Concurrent accord operations must be non-negative","messagePattern":"Concurrent accord operations must be non-negative","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":2986,"sourceCode":"        }\n        conf.concurrent_materialized_view_writes = concurrent_materialized_view_writes;\n    }\n\n    public static int getAccordConcurrentMigrationOps()\n    {\n        return conf.accord.migration_concurrency.or(2 * FBUtilities.getAvailableProcessors());\n    }\n\n    public static int getAccordConcurrentOps()\n    {\n        return conf.accord.queue_thread_count.or(2 * FBUtilities.getAvailableProcessors());\n    }\n\n    public static void setConcurrentAccordOps(int concurrent_operations)\n    {\n        if (concurrent_operations < 0)\n        {\n            throw new IllegalArgumentException(\"Concurrent accord operations must be non-negative\");\n        }\n        conf.accord.queue_thread_count = new OptionaldPositiveInt(concurrent_operations);\n    }\n\n    public static void setConcurrentAccordMigrationOps(int concurrent_operations)\n    {\n        if (concurrent_operations < 0)\n        {\n            throw new IllegalArgumentException(\"Concurrent accord operations must be non-negative\");\n        }\n        conf.accord.migration_concurrency = new OptionaldPositiveInt(concurrent_operations);\n    }\n\n    public static int getFlushWriters()\n    {\n        return conf.memtable_flush_writers;\n    }\n","sourceCodeStart":2968,"sourceCodeEnd":3004,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L2968-L3004","documentation":"DatabaseDescriptor.setConcurrentAccordOps validates the number of concurrent Accord transactional operations before storing it in the config. Cassandra requires a non-negative thread/operation count for the Accord queue; a negative value is nonsense and is rejected with IllegalArgumentException immediately.","triggerScenarios":"Calling DatabaseDescriptor.setConcurrentAccordOps(n) with n < 0, e.g. setConcurrentAccordOps(-1). Also reachable via JMX/nodetool setters that pass through a user-supplied negative concurrent_operations value.","commonSituations":"Operators computing the value dynamically (e.g. based on a delta or subtraction) that yields a negative; scripts or automation passing unvalidated integers; copy-paste mistakes in cassandra.yaml manipulation tools.","solutions":["Pass a value >= 0 (use 0 to let Cassandra use its default, since the field is an OptionaldPositiveInt).","Fix the upstream calculation or script that produced the negative number.","Clamp before calling: Math.max(0, concurrentOperations)."],"exampleFix":"// before\ndatabaseDescriptor.setConcurrentAccordOps(baseCount - extraCount); // may be negative\n// after\nint ops = Math.max(0, baseCount - extraCount);\ndatabaseDescriptor.setConcurrentAccordOps(ops);","handlingStrategy":"validation","validationCode":"if (concurrentOps >= 0) DatabaseDescriptor.setConcurrentAccordOps(concurrentOps); else throw new IllegalArgumentException(\"concurrentOps must be >= 0: \" + concurrentOps);","typeGuard":"boolean isValidAccordOps(int v) { return v >= 0; }","tryCatchPattern":"try { DatabaseDescriptor.setConcurrentAccordOps(ops); } catch (IllegalArgumentException e) { log.error(\"Invalid accord ops value\", e); ops = 0; DatabaseDescriptor.setConcurrentAccordOps(ops); }","preventionTips":["Clamp user-supplied integers with Math.max(0, v) before setter calls","Never pass raw arithmetic results that can go negative","Treat 0 as 'use default' rather than a negative placeholder"],"tags":["configuration","validation","accord"],"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"}