{"record":{"id":"6a5956136642eff8","repo":"quickwit-oss/quickwit","slug":"ack-id-not-found-in-in-flight","errorCode":null,"errorMessage":"ack_id {} not found in in-flight","messagePattern":"ack_id (.+?) not found in in-flight","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-indexing/src/source/queue_sources/memory_queue.rs","lineNumber":160,"sourceCode":"        for ack_id in ack_ids {\n            if let Some(msg) = inner_state.in_flight.remove(ack_id) {\n                inner_state.acked.push(msg);\n            }\n        }\n        Ok(())\n    }\n\n    async fn modify_deadlines(\n        &self,\n        ack_id: &str,\n        suggested_deadline: Duration,\n    ) -> anyhow::Result<Instant> {\n        let mut inner_state = self.inner_state.lock().unwrap();\n        let in_flight = inner_state.in_flight.get_mut(ack_id);\n        if let Some(msg) = in_flight {\n            msg.metadata.initial_deadline = Instant::now() + suggested_deadline;\n        } else {\n            bail!(\"ack_id {} not found in in-flight\", ack_id);\n        }\n        return Ok(Instant::now() + suggested_deadline);\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    fn prefilled_queue(nb_message: usize) -> Arc<MemoryQueueForTests> {\n        let memory_queue = MemoryQueueForTests::new();\n        for i in 0..nb_message {\n            let payload = format!(\"Test message {i}\");\n            let ack_id = i.to_string();\n            memory_queue.send_message(payload.clone(), &ack_id);\n        }\n        Arc::new(memory_queue)\n    }","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-indexing/src/source/queue_sources/memory_queue.rs#L142-L178","documentation":"MemoryQueue.modify_deadlines looks up the ack_id in the in-flight map and bails when it is absent, because deadline extension (visibility timeout renewal) can only apply to a message currently in flight. Once a message is acknowledged or expired/removed, its ack_id is no longer valid.","triggerScenarios":"Calling modify_deadlines(ack_id, ...) with an ack_id that was already acknowledged, removed after deadline expiry, or never issued for a message in the in-flight map.","commonSituations":"A processing task takes longer than the visibility deadline, the message expires out of in-flight, and then the task tries to extend its deadline; retry logic holding a stale ack_id; race between acknowledge and modify_deadlines.","solutions":["Extend the deadline before it expires; ensure the processing loop renews deadlines within the original visibility window.","Handle the Err case by treating the message as expired and reprocessing/re-consuming it rather than retrying with the stale ack_id.","Increase the initial deadline so long processing tasks do not expire mid-flight."],"exampleFix":"// before\nqueue.modify_deadlines(&stale_ack_id, Duration::from_secs(30)).await?;\n// after\nif queue.modify_deadlines(&ack_id, Duration::from_secs(30)).await.is_err() {\n    // message expired or was acked; re-fetch it instead of extending\n    return Err(anyhow::anyhow!(\"message expired, re-consume required\"));\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match queue.modify_deadlines(&ack_id, deadline).await {\n    Ok(_) => { /* deadline renewed */ }\n    Err(_) => { /* ack_id expired: drop the message and re-consume; do not retry with stale ack_id */ }\n}","preventionTips":["Renew deadlines well before the visibility timeout expires (e.g., at half the deadline).","Never cache ack_ids beyond the message's visibility window.","Size the initial deadline to exceed worst-case per-message processing time."],"tags":["queue","visibility-timeout","stale-ack","rust"],"backgroundTag":"resource-not-found","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}