{"record":{"id":"5c310cf839f6321d","repo":"Hmbown/CodeWhale","slug":"worker-worker-id-no-longer-has-that-running-fleet-task","errorCode":null,"errorMessage":"worker {worker_id} no longer has that running Fleet task","messagePattern":"worker (.+?) no longer has that running Fleet task","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":1057,"sourceCode":"\n    pub fn interrupt_worker(&self, worker_id: &str) -> Result<FleetWorkerInspection> {\n        let state = self.ledger.rebuild_state()?;\n        let Some(task) = active_task_for_worker(&state, worker_id) else {\n            return Err(FleetControlError::NoActiveTask {\n                worker_id: worker_id.to_string(),\n            }\n            .into());\n        };\n        let cancelled = self.ledger.cancel_task_if_active(\n            &task.entry.run_id,\n            &task.entry.task_id,\n            Some(worker_id),\n            &timestamp(),\n            Some(\"operator\"),\n            Some(\"operator\"),\n        )?;\n        if !cancelled {\n            bail!(\"worker {worker_id} no longer has that running Fleet task\");\n        }\n        self.refresh_run_status(&task.entry.run_id)?;\n        self.inspect_worker(worker_id)\n    }\n\n    pub fn restart_worker(&self, worker_id: &str) -> Result<FleetRestartReport> {\n        let state = self.ledger.rebuild_state()?;\n        let Some(task) = active_task_for_worker(&state, worker_id)\n            .or_else(|| latest_task_for_worker(&state, worker_id))\n        else {\n            bail!(\"worker {worker_id} has no Fleet task to restart\");\n        };\n        let run = state\n            .runs\n            .get(&task.entry.run_id.0)\n            .ok_or_else(|| anyhow!(\"Fleet run {} does not exist\", task.entry.run_id.0))?;\n        let max_workers = run\n            .max_workers","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/manager.rs#L1039-L1075","documentation":"FleetManager::interrupt_worker cancels a worker's active task via the compare-and-set ledger call cancel_task_if_active (crates/tui/src/fleet/manager.rs:1057). If the compare-and-set loses — the task was completed, cancelled, re-leased to another worker, or finished between the state rebuild and the cancel — the method reports that the worker no longer has that running Fleet task. It is a lost-race signal, not a data corruption error.","triggerScenarios":"Calling interrupt_worker(worker_id) when the worker's task terminated or changed ownership after active_task_for_worker() was evaluated: the worker completed its task concurrently, another operator already cancelled it, or a restart reassigned the lease.","commonSituations":"An operator pressing interrupt at the exact moment the worker finishes; a monitoring script issuing interrupts in a loop while tasks are completing; duplicate interrupt commands racing each other.","solutions":["Treat it as benign: re-inspect the worker (inspect_worker) to see its current state before retrying.","Re-run interrupt_worker only if inspection still shows an active task; otherwise the interrupt already happened or is unnecessary.","Serialize operator control commands (or check status first) so concurrent cancellations do not race."],"exampleFix":"// before\nmanager.interrupt_worker(&worker_id)?;\n// after\nmatch manager.interrupt_worker(&worker_id) {\n    Ok(inspection) => { /* cancelled */ }\n    Err(e) if e.to_string().contains(\"no longer has that running Fleet task\") => {\n        let state = manager.inspect_worker(&worker_id)?; // already terminal or reassigned\n    }\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"fallback","validationCode":"if let Some(task) = manager.inspect_worker(worker_id)?.current_task_id {\n    // worker still shows an active task; interrupt is likely to win\n}","typeGuard":null,"tryCatchPattern":"match manager.interrupt_worker(worker_id) {\n    Ok(insp) => insp,\n    Err(e) if e.to_string().contains(\"no longer has that running Fleet task\") => manager.inspect_worker(worker_id)?, // benign race\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Inspect the worker immediately before interrupting and accept lost races as no-ops.","Avoid issuing duplicate interrupts from scripts or concurrent operator sessions.","Serialize operator control commands against a shared lock when multiple clients manage the same run."],"tags":["fleet","race-condition","cancellation"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}