{"record":{"id":"4f34dc0794e42c2c","repo":"nautechsystems/nautilus_trader","slug":"failed-to-add-strategy-strategy-id-add-error","errorCode":null,"errorMessage":"Failed to add strategy {strategy_id}: {add_error}; failed to roll back external order claims: {rollback_error}","messagePattern":"Failed to add strategy (.+?): (.+?); failed to roll back external order claims: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/live/src/node/mod.rs","lineNumber":2747,"sourceCode":"                    && let Err(rollback_error) =\n                        self.rollback_external_order_claims(strategy_id, &instrument_ids)\n                {\n                    anyhow::bail!(\n                        \"{e}; failed to roll back external order claims for {strategy_id}: {rollback_error}\"\n                    );\n                }\n                return Err(e);\n            }\n        };\n\n        if let Err(add_error) = self.kernel.trader.borrow_mut().add_strategy(strategy) {\n            drop(exec_engine);\n\n            if !instrument_ids.is_empty()\n                && let Err(rollback_error) =\n                    self.rollback_external_order_claims(strategy_id, &instrument_ids)\n            {\n                anyhow::bail!(\n                    \"Failed to add strategy {strategy_id}: {add_error}; failed to roll back external order claims: {rollback_error}\"\n                );\n            }\n            return Err(add_error);\n        }\n\n        if let Some(exec_engine) = &mut exec_engine\n            && let Some(oms_type) = oms_type\n        {\n            exec_engine.register_oms_type(strategy_id, oms_type);\n        }\n\n        Ok(())\n    }\n\n    /// Registers external order claims in the shared cache.\n    ///\n    /// It can be called while the node is idle, after manual [`start`](Self::start) returns, or","sourceCodeStart":2729,"sourceCodeEnd":2765,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/node/mod.rs#L2729-L2765","documentation":"After `add_strategy` fails at a later stage (post exec-engine creation), the node attempts to roll back the external order claims it registered. If rollback fails, the error combines the original `add_error` with the `rollback_error`, indicating cleanup was incomplete and external order claims may remain registered for the strategy.","triggerScenarios":"Calling `add_strategy` where an error (`add_error`) occurs after claims were made on `instrument_ids` (e.g. strategy registration into the trader fails) AND `rollback_external_order_claims` returns `Err`.","commonSituations":"Adding a strategy whose instruments are already claimed by another strategy, or a trader/cache fault during registration, combined with a cache/redis outage preventing claim removal.","solutions":["Fix the original add failure shown as `Failed to add strategy {strategy_id}: {add_error}`.","Investigate the trailing `failed to roll back external order claims: {rollback_error}` — check cache connectivity and claim bookkeeping.","Restart the node or reset claim state before retrying the add.","Ensure no duplicate strategy_id or overlapping instrument claims with other running strategies."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if node.state() != NodeState::Idle {\n    anyhow::bail!(\"node must be idle before add_strategy\");\n}\nassert!(!strategy.instrument_ids().is_empty().then_some(true).is_none());","typeGuard":null,"tryCatchPattern":"if let Err(e) = node.add_strategy(strategy) {\n    let msg = e.to_string();\n    if msg.contains(\"failed to roll back external order claims\") {\n        // cleanup incomplete: verify claims, restart node before retry\n    }\n    return Err(e);\n}","preventionTips":["Verify the strategy registers cleanly (unique id, valid instruments) before adding.","Avoid duplicate strategy ids or overlapping instrument claims.","Keep the cache backend healthy; health-check it before node mutation."],"tags":["rollback-failure","error-chaining","live-node","strategy-registration"],"backgroundTag":"invalid-state-transition","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}