{"record":{"id":"85ddd9a3d1472c0f","repo":"Hmbown/CodeWhale","slug":"start-error-additionally-rollback-error","errorCode":null,"errorMessage":"{start_error:#}; additionally {rollback_error}","messagePattern":"(.+?); additionally (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":1401,"sourceCode":"                if let Some(guard) = coordination_guard.as_mut() {\n                    guard\n                        .register_worker_with_coordination(sub_agent_worker)\n                        .map_err(anyhow::Error::msg)?;\n                    registration_succeeded = true;\n                }\n                Ok(())\n            },\n        );\n        let started = match start_result {\n            Ok(started) => started,\n            Err(start_error) => {\n                if registration_succeeded\n                    && let (Some(guard), Some(snapshot)) =\n                        (coordination_guard.as_mut(), registration_snapshot)\n                    && let Err(rollback_error) =\n                        guard.restore_coordination_registration_snapshot(snapshot)\n                {\n                    return Err(anyhow!(\"{start_error:#}; additionally {rollback_error}\"));\n                }\n                return Err(start_error);\n            }\n        };\n        if !started {\n            return Ok(false);\n        }\n\n        Ok(true)\n    }\n\n    fn start_leased_workers(\n        &self,\n        run_id: &FleetRunId,\n        executor: &mut FleetExecutor,\n        codewhale_binary: &str,\n        model: Option<&str>,\n    ) -> Result<usize> {","sourceCodeStart":1383,"sourceCodeEnd":1419,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/manager.rs#L1383-L1419","documentation":"When a task start fails after the worker was already registered in coordination state, the manager rolls back the registration by restoring a pre-registration snapshot. If the rollback itself also fails, both errors are chained into one message: the original start error plus 'additionally <rollback error>'. This preserves the primary cause while surfacing that coordination state may now hold a stale registration.","triggerScenarios":"start_task_if_enqueued fails (ledger race, cancellation won, constraint violated) after register_worker_with_coordination succeeded, and restore_coordination_registration_snapshot also errors.","commonSituations":"High contention between operator commands and the scheduler so the ledger claim fails mid-start; concurrent cancellation between registration and ledger transition; lock/state drift in SubAgentManager.","solutions":["Inspect the chained message: fix the primary start_error first, it is the root cause","Reconcile the worker's coordination registration (unregister stale record) before retrying","Stop and re-lease the task cleanly instead of retrying the start in place","Reduce concurrency on the run so cancellation cannot race the start transition"],"exampleFix":"// before\nreturn Err(anyhow!(\"{start_error:#}; additionally {rollback_error}\"));\n// after\nreturn Err(anyhow!(\n    \"start failed and registration rollback also failed; \\\n     manually unregister worker before retrying: {start_error:#}; rollback: {rollback_error}\"\n));","handlingStrategy":"try-catch","validationCode":"// Avoid the race upstream: check the task is still enqueued right before starting.\nif manager.task_status(&run_id, &task_id) != Some(FleetTaskStatus::Enqueued) {\n    return Ok(false);\n}","typeGuard":null,"tryCatchPattern":"// The message chains root cause first: \"{start_error:#}; additionally {rollback_error}\"\nmatch result {\n    Err(e) if e.to_string().contains(\"additionally\") => {\n        let (start_err, rollback_err) = split_chain(&e);\n        reconcile_worker_registration(worker_id); // clean stale registration\n        Err(anyhow!(\"start failed: {start_err}\"))\n    }\n    other => other,\n}","preventionTips":["Minimize concurrent cancel/start operations on the same task","After any compound error, verify and clean the worker's coordination registration before retrying","Read the full chained message — the first segment is the root cause"],"tags":["fleet","rollback","registration","compound-error"],"backgroundTag":"internal-invariant-violation","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"}