{"record":{"id":"119b19f92760d5d9","repo":"Hmbown/CodeWhale","slug":"fleet-coordination-state-is-busy-retry-resume","errorCode":null,"errorMessage":"Fleet coordination state is busy; retry resume","messagePattern":"Fleet coordination state is busy; retry resume","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":698,"sourceCode":"        // Reuse the shared scheduler recovery engine over the same ledger so\n        // resume and steady-state supervision converge on one store and one\n        // retry/escalation policy. The manager's `stale_after` becomes the\n        // scheduler's heartbeat timeout so both surfaces agree on staleness.\n        let policy = FleetSchedulerPolicy {\n            heartbeat_timeout: self.stale_after,\n            ..FleetSchedulerPolicy::default()\n        };\n        let mut scheduler = FleetScheduler::open(&self.workspace, policy)?;\n        scheduler.set_now(now);\n        // Keep the lock order coordination -> ledger. A restart generation is\n        // durably prepared by the callback before the scheduler publishes the\n        // replacement lease, and an exact one-generation-ahead preparation is\n        // safe to consume after a process crash.\n        let mut coordination_guard = match &self.sub_agent_manager {\n            Some(manager) => Some(\n                manager\n                    .try_write()\n                    .map_err(|_| anyhow!(\"Fleet coordination state is busy; retry resume\"))?,\n            ),\n            None => None,\n        };\n        let report = scheduler.resume_run_with_restart_callback(\n            run_id,\n            |state, task, task_spec, worker_id| {\n                if let Some(guard) = coordination_guard.as_mut() {\n                    self.prepare_registered_restart_generation(\n                        guard, state, task, task_spec, worker_id,\n                    )?;\n                }\n                Ok(())\n            },\n        )?;\n        let status = self.run_status(run_id)?;\n        Ok(FleetResumeReport {\n            run_id: run_id.clone(),\n            reclaimed_stale: report.marked_stale,","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/manager.rs#L680-L716","documentation":"FleetManager::resume_run_at needs an exclusive write lock on the shared SubAgentManager coordination state before reconciling stale leases. It uses try_write() so it never blocks, and returns this error when another thread currently holds the coordination lock (read or write). Resume is idempotent and safe to call again, so the error is an explicit 'retry' signal rather than a corruption report.","triggerScenarios":"Calling resume_run() (or resume_run_at()) while another thread holds the sub_agent_manager write lock — e.g. a concurrent restart_worker(), start_run, or any long-lived coordination write scope.","commonSituations":"UI command handler and a background supervision loop both triggering fleet operations; two operator commands racing after a crash recovery; lock held by a slow prepare_registered_restart_generation callback.","solutions":["Retry resume_run() after a short delay; the lock holder will release it","Serialize fleet operations so resume is not called concurrently with restart/start paths","Check that no other component holds the SubAgentManager write lock longer than needed","If resume repeatedly fails, find the stuck lock holder via logs around the last fleet command"],"exampleFix":"// before\nlet report = manager.resume_run(&run_id)?;\n// after\nlet report = loop {\n    match manager.resume_run(&run_id) {\n        Ok(r) => break r,\n        Err(e) if e.to_string().contains(\"coordination state is busy\") => std::thread::sleep(Duration::from_millis(100)),\n        Err(e) => return Err(e),\n    }\n};","handlingStrategy":"retry","validationCode":"// Coordinator is an RwLock; probe availability before resuming.\nfn coordination_available(manager: &FleetManager) -> bool { manager.try_probe_coordination_lock() }","typeGuard":null,"tryCatchPattern":"match manager.resume_run(&run_id) {\n    Err(e) if e.to_string().contains(\"coordination state is busy\") => retry_with_backoff(),\n    Err(e) => return Err(e),\n    Ok(report) => Ok(report),\n}","preventionTips":["Serialize fleet commands through one queue instead of concurrent resume/restart calls","Keep coordination lock scopes short — never hold the write lock across slow I/O","Treat this error as retryable by default; resume is idempotent"],"tags":["fleet","lock-contention","retry","concurrency"],"backgroundTag":"resource-temporarily-unavailable","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"}