{"record":{"id":"1dc89e4642718465","repo":"apache/cassandra","slug":"concurrent-writes-must-be-at-least-2-but-was-co","errorCode":null,"errorMessage":"concurrent_writes must be at least 2, but was ${conf.concurrent_writes}","messagePattern":"concurrent_writes must be at least 2, but was (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":733,"sourceCode":"                                               \"(options: direct/auto) \" + conf.compaction_read_disk_access_mode);\n        }\n        logger.info(\"compaction_read_disk_access_mode resolved to: {}\", compactionReadDiskAccessMode);\n\n        /* phi convict threshold for FailureDetector */\n        if (conf.phi_convict_threshold < 5 || conf.phi_convict_threshold > 16)\n        {\n            throw new ConfigurationException(\"phi_convict_threshold must be between 5 and 16, but was \" + conf.phi_convict_threshold, false);\n        }\n\n        /* Thread per pool */\n        if (conf.concurrent_reads < 2)\n        {\n            throw new ConfigurationException(\"concurrent_reads must be at least 2, but was \" + conf.concurrent_reads, false);\n        }\n\n        if (conf.concurrent_writes < 2 && TEST_FAIL_MV_LOCKS_COUNT.getString(\"\").isEmpty())\n        {\n            throw new ConfigurationException(\"concurrent_writes must be at least 2, but was \" + conf.concurrent_writes, false);\n        }\n\n        if (conf.concurrent_counter_writes < 2)\n            throw new ConfigurationException(\"concurrent_counter_writes must be at least 2, but was \" + conf.concurrent_counter_writes, false);\n\n        if (conf.networking_cache_size == null)\n            conf.networking_cache_size = new DataStorageSpec.IntMebibytesBound(Math.min(128, (int) (Runtime.getRuntime().maxMemory() / (16 * 1048576))));\n\n        if (conf.file_cache_size == null)\n            conf.file_cache_size = new DataStorageSpec.IntMebibytesBound(Math.min(512, (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576))));\n\n        // round down for SSDs and round up for spinning disks\n        if (conf.file_cache_round_up == null)\n            conf.file_cache_round_up = conf.disk_optimization_strategy == Config.DiskOptimizationStrategy.spinning;\n\n        if (conf.memtable_offheap_space == null)\n            conf.memtable_offheap_space = new DataStorageSpec.IntMebibytesBound((int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)));\n        // for the moment, we default to twice as much on-heap space as off-heap, as heap overhead is very large","sourceCodeStart":715,"sourceCodeEnd":751,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L715-L751","documentation":"concurrent_writes sets the write stage worker thread count and must be at least 2. applySimpleConfig enforces this at startup, but skips the check while the TEST_FAIL_MV_LOCKS_COUNT system property is set, which some materialized-view tests use to run with degenerate pools.","triggerScenarios":"cassandra.yaml (or programmatic Config) has `concurrent_writes` below 2 (e.g. 0 or 1) when DatabaseDescriptor.toolInitialization/applyAll runs, and the TEST_FAIL_MV_LOCKS_COUNT system property is unset/empty.","commonSituations":"Shrinking pools on memory-constrained containers; CI images with generated configs producing 0/1; mixing test-only property flags into production startup scripts that then behave differently from expected.","solutions":["Set `concurrent_writes` to at least 2 (shipped default is 32).","Remove the override to use the default.","If a test harness intentionally sets low values, ensure TEST_FAIL_MV_LOCKS_COUNT is only set in test environments, never in production."],"exampleFix":"// before (cassandra.yaml)\nconcurrent_writes: 0\n// after (cassandra.yaml)\nconcurrent_writes: 32","handlingStrategy":"validation","validationCode":"// Java, before toolInitialization()\nint writes = /* configured concurrent_writes */;\nboolean testFlag = !System.getProperty(\"cassandra.test.fail_mv_locks_count\", \"\").isEmpty();\nif (writes < 2 && !testFlag)\n    throw new IllegalArgumentException(\"concurrent_writes must be >= 2, got \" + writes);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never let test-only system properties leak into production startup scripts.","Clamp generated pool sizes to >= 2.","Prefer removing overrides over hand-tuning tiny pool sizes."],"tags":["config","thread-pools","validation","startup"],"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"}