{"record":{"id":"d4562f0cfebc5572","repo":"apache/cassandra","slug":"memtable-flush-writers-must-be-at-least-1-but-was","errorCode":null,"errorMessage":"memtable_flush_writers must be at least 1, but was ${conf.memtable_flush_writers}","messagePattern":"memtable_flush_writers must be at least 1, but was (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":944,"sourceCode":"            throw new ConfigurationException(\"saved_caches_directory must not be the same as the commitlog_directory\", false);\n\n        if (conf.accord.journal_directory.equals(conf.hints_directory))\n            throw new ConfigurationException(\"hints_directory must not be the same as the accord.journal_directory\", false);\n        if (conf.accord.journal_directory.equals(conf.saved_caches_directory))\n            throw new ConfigurationException(\"saved_caches_directory must not be the same as the accord.journal_directory\", false);\n\n        if (conf.hints_directory.equals(conf.saved_caches_directory))\n            throw new ConfigurationException(\"saved_caches_directory must not be the same as the hints_directory\", false);\n\n        initializeBackgroundWriteDiskAccessMode();\n\n        if (conf.memtable_flush_writers == 0)\n        {\n            conf.memtable_flush_writers = conf.data_file_directories.length == 1 ? 2 : 1;\n        }\n\n        if (conf.memtable_flush_writers < 1)\n            throw new ConfigurationException(\"memtable_flush_writers must be at least 1, but was \" + conf.memtable_flush_writers, false);\n\n        if (conf.memtable_cleanup_threshold == null)\n        {\n            conf.memtable_cleanup_threshold = (float) (1.0 / (1 + conf.memtable_flush_writers));\n        }\n        else\n        {\n            logger.warn(\"memtable_cleanup_threshold has been deprecated and should be removed from cassandra.yaml\");\n        }\n\n        if (conf.memtable_cleanup_threshold < 0.01f)\n            throw new ConfigurationException(\"memtable_cleanup_threshold must be >= 0.01, but was \" + conf.memtable_cleanup_threshold, false);\n        if (conf.memtable_cleanup_threshold > 0.99f)\n            throw new ConfigurationException(\"memtable_cleanup_threshold must be <= 0.99, but was \" + conf.memtable_cleanup_threshold, false);\n        if (conf.memtable_cleanup_threshold < 0.1f)\n            logger.warn(\"memtable_cleanup_threshold is set very low [{}], which may cause performance degradation\", conf.memtable_cleanup_threshold);\n\n        if (conf.concurrent_compactors == null)","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L926-L962","documentation":"DatabaseDescriptor.applySimpleConfig throws this ConfigurationException when the configured memtable_flush_writers value is below 1. Cassandra auto-defaults a value of 0 based on the number of data directories, but any explicitly negative or sub-1 value is rejected because Cassandra needs at least one thread to flush memtables to SSTables.","triggerScenarios":"Set memtable_flush_writers to a negative number (e.g. -1) in cassandra.yaml and start the node; validation happens in applySimpleConfig after the ==0 auto-default, during toolInitialization/applyAll.","commonSituations":"Hand-tuning to reduce memory footprint with an invalid 0 or negative value; templating bugs where a computed value evaluated to a negative number; stale docs recommending 0 to disable flushing.","solutions":["Set memtable_flush_writers to a positive integer in cassandra.yaml (e.g. 2).","Remove the setting entirely to let Cassandra derive a default from the number of data_file_directories.","Clamp computed values in config-generation scripts to at least 1 before writing cassandra.yaml."],"exampleFix":"// before (cassandra.yaml)\nmemtable_flush_writers: -1\n// after\nmemtable_flush_writers: 2","handlingStrategy":"validation","validationCode":"int writers = cfg.memtable_flush_writers;\nif (writers < 1)\n    throw new IllegalArgumentException(\"memtable_flush_writers must be >= 1, was \" + writers);\n// 0 is allowed upstream (auto-defaulted), but safest to set an explicit positive value","typeGuard":"boolean validFlushWriters(int v) { return v >= 1; }","tryCatchPattern":"try { DatabaseDescriptor.applyAll(cfg); } catch (ConfigurationException e) { logger.error(\"Invalid memtable_flush_writers: {}\", e.getMessage()); System.exit(1); }","preventionTips":["Only set memtable_flush_writers to a positive integer; unset it to auto-default","Clamp template/script-generated values to >= 1 before writing cassandra.yaml","Validate tuning changes in a test node before production rollout"],"tags":["config","startup","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"}