{"record":{"id":"4de5672e04a044a2","repo":"valeriansaliou/sonic","slug":"write-buffer-for-kv-must-not-be-zero","errorCode":null,"errorMessage":"write_buffer for kv must not be zero","messagePattern":"write_buffer for kv must not be zero","errorType":"validation","errorClass":"panic","httpStatus":null,"severity":"critical","filePath":"core/src/config.rs","lineNumber":38,"sourceCode":"\n#[derive(Deserialize)]\npub struct Config {\n    pub normalization: ConfigNormalization,\n\n    pub tokenization: ConfigTokenization,\n\n    pub stopwords: ConfigStopwords,\n\n    pub search: ConfigSearch,\n\n    pub store: ConfigStore,\n}\n\nimpl Config {\n    pub fn validate(&self) {\n        // Check 'write_buffer' for KV\n        if self.store.kv.database.write_buffer_size == Some(0) {\n            panic!(\"write_buffer for kv must not be zero\");\n        }\n\n        // Check 'flush_after' for KV\n        if self.store.kv.database.flush_after >= self.store.kv.pool.inactive_after {\n            panic!(\"flush_after for kv must be strictly lower than inactive_after\");\n        }\n\n        // Check 'flush_after' for KV\n        if self.store.kv.database.max_flushes.is_some()\n            && self.store.kv.database.max_background_jobs.is_some()\n        {\n            panic!(\"max_background_jobs makes max_flushes unneeded, don’t configure both\");\n        }\n\n        // Check 'consolidate_after' for FST\n        if self.store.fst.graph.consolidate_after >= self.store.fst.pool.inactive_after {\n            panic!(\"consolidate_after for fst must be strictly lower than inactive_after\");\n        }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/valeriansaliou/sonic/blob/e6a72da6a532bc3f31d7d93ef1e0964a1a5d01b2/core/src/config.rs#L20-L56","documentation":"Sonic's Config::validate() panics if the KV store's write_buffer_size is explicitly set to Some(0). A zero-sized write buffer means the KV engine could never buffer writes before flushing, which is an invalid configuration. The panic happens at startup, before the server accepts traffic.","triggerScenarios":"Setting store.kv.database.write_buffer_size = 0 in the TOML config file and starting the server (Config::validate runs during boot).","commonSituations":"Hand-edited TOML configs where a user 'disables' buffering by setting 0; templated configs filling an option with 0; misunderstanding that the Option means 'unset', so 0 must simply be omitted.","solutions":["Remove the write_buffer_size key from the [store.kv.database] section to use the default","Set write_buffer_size to a positive value (e.g. 1024)","Restart the server after fixing the config"],"exampleFix":"// config.toml\n// before\n[store.kv.database]\nwrite_buffer_size = 0\n\n// after\n[store.kv.database]\nwrite_buffer_size = 1024","handlingStrategy":"validation","validationCode":"// before starting the server\nlet cfg = config_from_toml(&raw);\nif cfg.store.kv.database.write_buffer_size == Some(0) {\n    return Err(\"store.kv.database.write_buffer_size must be > 0 or omitted\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set write_buffer_size: 0; omit the key for defaults","Validate config files in CI before deployment","Add a smoke test that boots the server with your production config"],"tags":["config","panic","startup","kv"],"backgroundTag":"invalid-config-value","analyzedSha":"e6a72da6a532bc3f31d7d93ef1e0964a1a5d01b2","analyzedAt":"2026-09-01T14:10:00.384Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}