nautechsystems/nautilus_trader · error

Failed to add strategy {strategy_id}: {add_error}; failed to

Error message

Failed to add strategy {strategy_id}: {add_error}; failed to roll back external order claims: {rollback_error}

What it means

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.

Source

Thrown at crates/live/src/node/mod.rs:2747

                    && let Err(rollback_error) =
                        self.rollback_external_order_claims(strategy_id, &instrument_ids)
                {
                    anyhow::bail!(
                        "{e}; failed to roll back external order claims for {strategy_id}: {rollback_error}"
                    );
                }
                return Err(e);
            }
        };

        if let Err(add_error) = self.kernel.trader.borrow_mut().add_strategy(strategy) {
            drop(exec_engine);

            if !instrument_ids.is_empty()
                && let Err(rollback_error) =
                    self.rollback_external_order_claims(strategy_id, &instrument_ids)
            {
                anyhow::bail!(
                    "Failed to add strategy {strategy_id}: {add_error}; failed to roll back external order claims: {rollback_error}"
                );
            }
            return Err(add_error);
        }

        if let Some(exec_engine) = &mut exec_engine
            && let Some(oms_type) = oms_type
        {
            exec_engine.register_oms_type(strategy_id, oms_type);
        }

        Ok(())
    }

    /// Registers external order claims in the shared cache.
    ///
    /// It can be called while the node is idle, after manual [`start`](Self::start) returns, or

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Fix the original add failure shown as `Failed to add strategy {strategy_id}: {add_error}`.
  2. Investigate the trailing `failed to roll back external order claims: {rollback_error}` — check cache connectivity and claim bookkeeping.
  3. Restart the node or reset claim state before retrying the add.
  4. Ensure no duplicate strategy_id or overlapping instrument claims with other running strategies.
Defensive patterns

Strategy: try-catch

Validate before calling

if node.state() != NodeState::Idle {
    anyhow::bail!("node must be idle before add_strategy");
}
assert!(!strategy.instrument_ids().is_empty().then_some(true).is_none());

Try / catch

if let Err(e) = node.add_strategy(strategy) {
    let msg = e.to_string();
    if msg.contains("failed to roll back external order claims") {
        // cleanup incomplete: verify claims, restart node before retry
    }
    return Err(e);
}

Prevention

When it happens

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

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

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/4f34dc0794e42c2c. Report an issue: GitHub.