Hmbown/CodeWhale · warning

Fleet coordination state is busy; retry resume

Error message

Fleet coordination state is busy; retry resume

What it means

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.

Solutions

  1. Retry resume_run() after a short delay; the lock holder will release it
  2. Serialize fleet operations so resume is not called concurrently with restart/start paths
  3. Check that no other component holds the SubAgentManager write lock longer than needed
  4. If resume repeatedly fails, find the stuck lock holder via logs around the last fleet command

Example fix

// before
let report = manager.resume_run(&run_id)?;
// after
let report = loop {
    match manager.resume_run(&run_id) {
        Ok(r) => break r,
        Err(e) if e.to_string().contains("coordination state is busy") => std::thread::sleep(Duration::from_millis(100)),
        Err(e) => return Err(e),
    }
};
Defensive patterns

Strategy: retry

Validate before calling

// Coordinator is an RwLock; probe availability before resuming.
fn coordination_available(manager: &FleetManager) -> bool { manager.try_probe_coordination_lock() }

Try / catch

match manager.resume_run(&run_id) {
    Err(e) if e.to_string().contains("coordination state is busy") => retry_with_backoff(),
    Err(e) => return Err(e),
    Ok(report) => Ok(report),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/119b19f92760d5d9. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/fleet/manager.rs:698

        // Reuse the shared scheduler recovery engine over the same ledger so
        // resume and steady-state supervision converge on one store and one
        // retry/escalation policy. The manager's `stale_after` becomes the
        // scheduler's heartbeat timeout so both surfaces agree on staleness.
        let policy = FleetSchedulerPolicy {
            heartbeat_timeout: self.stale_after,
            ..FleetSchedulerPolicy::default()
        };
        let mut scheduler = FleetScheduler::open(&self.workspace, policy)?;
        scheduler.set_now(now);
        // Keep the lock order coordination -> ledger. A restart generation is
        // durably prepared by the callback before the scheduler publishes the
        // replacement lease, and an exact one-generation-ahead preparation is
        // safe to consume after a process crash.
        let mut coordination_guard = match &self.sub_agent_manager {
            Some(manager) => Some(
                manager
                    .try_write()
                    .map_err(|_| anyhow!("Fleet coordination state is busy; retry resume"))?,
            ),
            None => None,
        };
        let report = scheduler.resume_run_with_restart_callback(
            run_id,
            |state, task, task_spec, worker_id| {
                if let Some(guard) = coordination_guard.as_mut() {
                    self.prepare_registered_restart_generation(
                        guard, state, task, task_spec, worker_id,
                    )?;
                }
                Ok(())
            },
        )?;
        let status = self.run_status(run_id)?;
        Ok(FleetResumeReport {
            run_id: run_id.clone(),
            reclaimed_stale: report.marked_stale,

View on GitHub (pinned to 73e0f67d83)