{"record":{"id":"9a45e9a3369df53f","repo":"vectordotdev/vector","slug":"the-drain-timeout-ms-must-be-less-than-sessio","errorCode":null,"errorMessage":"The drain_timeout_ms ({}) must be less than session_timeout_ms ({})","messagePattern":"The drain_timeout_ms \\((.+?)\\) must be less than session_timeout_ms \\((.+?)\\)","errorType":"validation","errorClass":"BuildError::InvalidDrainTimeout","httpStatus":null,"severity":"error","filePath":"src/sources/kafka.rs","lineNumber":342,"sourceCode":"\n#[async_trait::async_trait]\n#[typetag::serde(name = \"kafka\")]\nimpl SourceConfig for KafkaSourceConfig {\n    async fn build(&self, cx: SourceContext) -> crate::Result<super::Source> {\n        let log_namespace = cx.log_namespace(self.log_namespace);\n\n        let decoder =\n            DecodingConfig::new(self.framing.clone(), self.decoding.clone(), log_namespace)\n                .build()?;\n        let decompressor = self\n            .decompression\n            .as_ref()\n            .map(DecompressionConfig::build)\n            .transpose()?;\n        let acknowledgements = cx.do_acknowledgements(self.acknowledgements);\n\n        if let Some(d) = self.drain_timeout_ms {\n            snafu::ensure!(\n                Duration::from_millis(d) <= self.session_timeout_ms,\n                InvalidDrainTimeoutSnafu {\n                    value: d,\n                    session_timeout_ms: self.session_timeout_ms\n                }\n            );\n        }\n\n        let (consumer, callback_rx) = create_consumer(self, acknowledgements)?;\n\n        Ok(Box::pin(kafka_source(\n            self.clone(),\n            consumer,\n            callback_rx,\n            decoder,\n            decompressor,\n            cx.out,\n            cx.shutdown,","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sources/kafka.rs#L324-L360","documentation":"The Kafka source validates that drain_timeout_ms, the grace period given to in-flight messages during shutdown, is not longer than session_timeout_ms, the Kafka consumer session timeout. This error is raised at source build time when drain_timeout_ms exceeds the session timeout, because a drain period longer than the session would let the consumer be kicked from the group mid-drain.","triggerScenarios":"Configuring a Kafka source with drain_timeout_ms set to a value greater than session_timeout_ms (strictly less-than is required by the message text; the code checks d <= session_timeout_ms and errors otherwise).","commonSituations":"Operators tuning shutdown behavior set a long drain_timeout_ms while leaving the default session_timeout_ms; copying a source config between clusters with different session timeouts.","solutions":["Lower drain_timeout_ms so it is <= session_timeout_ms (and per the message, less than it).","Or raise session_timeout_ms to exceed the desired drain timeout.","Remove drain_timeout_ms to use the default behavior."],"exampleFix":"// before (vector.yaml)\nsources:\n  kafka_in:\n    type: kafka\n    session_timeout_ms: 10000\n    drain_timeout_ms: 30000\n// after\nsources:\n  kafka_in:\n    type: kafka\n    session_timeout_ms: 10000\n    drain_timeout_ms: 5000","handlingStrategy":"validation","validationCode":"// pre-check config values before loading\nfn drain_timeout_ok(drain_timeout_ms: u64, session_timeout_ms: u64) -> bool {\n    drain_timeout_ms <= session_timeout_ms\n}","typeGuard":null,"tryCatchPattern":"match Vector::build() {\n    Err(e) if e.to_string().contains(\"drain_timeout_ms\") => {\n        eprintln!(\"adjust drain_timeout_ms <= session_timeout_ms\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Keep drain_timeout_ms well below session_timeout_ms (e.g. 1/10th).","Run vector validate on configs before deploying.","Document session timeout changes when tuning shutdown behavior."],"tags":["kafka","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}