{"record":{"id":"fdcbf1bcbaa5fd70","repo":"nautechsystems/nautilus_trader","slug":"failed-to-load-actor-actor-id-state-e","errorCode":null,"errorMessage":"Failed to load actor {actor_id} state: {e:#}","messagePattern":"Failed to load actor (.+?) state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1585,"sourceCode":"    /// Returns an error if state cannot be loaded or a component callback fails.\n    pub(crate) fn load_state(trader: &Rc<RefCell<Self>>) -> anyhow::Result<()> {\n        let (cache, actor_callbacks, strategy_callbacks) = {\n            let trader = trader.borrow();\n            let actor_callbacks = trader.actor_state_callbacks()?;\n            let strategy_callbacks = trader.strategy_state_callbacks()?;\n\n            (trader.cache.clone(), actor_callbacks, strategy_callbacks)\n        };\n\n        if !cache.borrow().has_backing() {\n            return Ok(());\n        }\n\n        for (actor_id, callbacks) in actor_callbacks {\n            let state = cache\n                .borrow()\n                .load_actor_state(&actor_id)\n                .map_err(|e| anyhow::anyhow!(\"Failed to load actor {actor_id} state: {e:#}\"))?;\n            let Some(state) = state.filter(|state| !state.is_empty()) else {\n                continue;\n            };\n\n            (callbacks.load)(actor_id.inner(), state)\n                .map_err(|e| anyhow::anyhow!(\"Failed to restore actor {actor_id} state: {e:#}\"))?;\n        }\n\n        for (strategy_id, callbacks) in strategy_callbacks {\n            let state = cache\n                .borrow()\n                .load_strategy_state(&strategy_id)\n                .map_err(|e| {\n                    anyhow::anyhow!(\"Failed to load strategy {strategy_id} state: {e:#}\")\n                })?;\n            let Some(state) = state.filter(|state| !state.is_empty()) else {\n                continue;\n            };","sourceCodeStart":1567,"sourceCodeEnd":1603,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1567-L1603","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before start with recovery: ping the backing store\nif !cache_backend.ping() { return Err(\"cache backend unreachable\"); }","typeGuard":null,"tryCatchPattern":"match system.start_with_recovery() {\n    Err(e) if e.to_string().contains(\"Failed to load actor\") => {\n        // fix backend connectivity/config, then retry start\n    }\n    other => other?,\n}","preventionTips":["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"],"tags":["state","persistence","actor","cache"],"backgroundTag":"state-load-failed","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"}