nautechsystems/nautilus_trader · error
Failed to load actor {actor_id} state: {e:#}
Error message
Failed to load actor {actor_id} state: {e:#} What it means
Raised in `Trader::load_state` when the cache fails to load previously persisted state for an actor (`cache.load_actor_state`). The trader is restoring actors from a backing store (e.g. Redis-backed cache) after restart; if the read fails, the whole state-restore pass aborts with this message so actors are not silently started with missing state.
Source
Thrown at crates/system/src/trader.rs:1585
/// Returns an error if state cannot be loaded or a component callback fails.
pub(crate) fn load_state(trader: &Rc<RefCell<Self>>) -> anyhow::Result<()> {
let (cache, actor_callbacks, strategy_callbacks) = {
let trader = trader.borrow();
let actor_callbacks = trader.actor_state_callbacks()?;
let strategy_callbacks = trader.strategy_state_callbacks()?;
(trader.cache.clone(), actor_callbacks, strategy_callbacks)
};
if !cache.borrow().has_backing() {
return Ok(());
}
for (actor_id, callbacks) in actor_callbacks {
let state = cache
.borrow()
.load_actor_state(&actor_id)
.map_err(|e| anyhow::anyhow!("Failed to load actor {actor_id} state: {e:#}"))?;
let Some(state) = state.filter(|state| !state.is_empty()) else {
continue;
};
(callbacks.load)(actor_id.inner(), state)
.map_err(|e| anyhow::anyhow!("Failed to restore actor {actor_id} state: {e:#}"))?;
}
for (strategy_id, callbacks) in strategy_callbacks {
let state = cache
.borrow()
.load_strategy_state(&strategy_id)
.map_err(|e| {
anyhow::anyhow!("Failed to load strategy {strategy_id} state: {e:#}")
})?;
let Some(state) = state.filter(|state| !state.is_empty()) else {
continue;
};View on GitHub (pinned to 18893faf8b)
Solutions
- Check the wrapped `{e:#}` chain for the underlying cause (connection refused, auth, deserialization) and fix the backing store first
- Verify the cache backend (e.g. Redis) is reachable and credentials/config in the system config are correct
- Confirm the persisted state was written by a compatible library version; re-save state or clear the stale key if the schema changed
- If the state is unrecoverable, delete the actor's persisted key and restart, accepting the actor starts with empty state
Defensive patterns
Strategy: retry
Validate before calling
// before start with recovery: ping the backing store
if !cache_backend.ping() { return Err("cache backend unreachable"); } Try / catch
match system.start_with_recovery() {
Err(e) if e.to_string().contains("Failed to load actor") => {
// fix backend connectivity/config, then retry start
}
other => other?,
} Prevention
- Health-check the cache backend (Redis etc.) before starting the trader
- Keep cache credentials in env/config consistent across restarts
- Avoid schema-breaking upgrades without clearing or migrating persisted state
- Monitor the wrapped error chain (`{e:#}`) for the true root cause
When it happens
Trigger: Calling trader start/`load_state` with state recovery enabled when `load_actor_state(actor_id)` returns an error — typically a backing-store connection failure, corrupted key, or serialization error for that actor's state key.
Common situations: Restarting a live trading node with a Redis cache whose connection dropped or credentials changed; persisted state was written by a different schema version; the actor's state key was deleted/expired in the backing store.
Related errors
- Failed to restore actor {actor_id} state: {e:#}
- Failed to load strategy {strategy_id} state: {e:#}
- DataActor {} must be registered before calling `cache()` - t
- DataActor {actor_id} already registered with trader {existin
- load_actor not implemented for PostgreSQL cache adapter: {ac
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/fdcbf1bcbaa5fd70.
Report an issue: GitHub.