{"record":{"id":"0ccbb1b0e37cc8ec","repo":"nautechsystems/nautilus_trader","slug":"failed-to-load-actor-and-strategy-state-e","errorCode":null,"errorMessage":"Failed to load actor and strategy state: {e:#}","messagePattern":"Failed to load actor and strategy state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/system/src/kernel.rs","lineNumber":796,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if the trader or a registered component fails to start. A failed partial\n    /// start is stopped immediately before the error is returned.\n    pub fn start_trader(&mut self) -> anyhow::Result<()> {\n        log::info!(\"Starting trader...\");\n\n        let load_state = self.config.load_state();\n        let save_state = self.config.save_state();\n\n        if (load_state || save_state) && !self.cache.borrow().has_backing() {\n            log::warn!(\n                \"Cache has no database backing, load_state={load_state} and save_state={save_state} will have no effect\"\n            );\n        }\n\n        if load_state {\n            Trader::load_state(&self.trader)\n                .map_err(|e| anyhow::anyhow!(\"Failed to load actor and strategy state: {e:#}\"))?;\n        }\n\n        self.state_save_armed = save_state;\n        self.order_emulator.start();\n\n        if let Err(start_err) = Trader::start_with_component_callbacks(&self.trader) {\n            let stop_result = self.stop_trader_after_start_failure();\n            self.order_emulator.stop();\n            let save_result = self.save_trader_state();\n\n            let mut errors = vec![format!(\"Failed to start trader: {start_err}\")];\n            if let Err(e) = stop_result {\n                errors.push(format!(\"failed to stop partial trader start: {e}\"));\n            }\n\n            if let Err(e) = save_result {\n                errors.push(format!(\"failed to save partial trader state: {e}\"));\n            }","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/kernel.rs#L778-L814","documentation":"During `Kernel::start_trader`, if `load_state` is enabled the trader calls `Trader::load_state` to restore actor/strategy persisted state from the cache database. Any failure (deserialization, missing/corrupt snapshot, DB error) is wrapped into this anyhow error and aborts startup.","triggerScenarios":"Configuring a kernel/node with `load_state=true` while the backing cache database is missing, corrupt, or holds state written by an incompatible schema/serializer version.","commonSituations":"Restoring a trader against a Redis/Postgres/backed cache after a nautilus_trader version upgrade changed the state schema; pointing at a database directory that was deleted; corrupted snapshot files.","solutions":["Read the inner `{e:#}` chain to identify the root cause (which actor/strategy or key failed).","Verify the cache database config (path/connection) and that the DB is reachable and readable.","Re-export or regenerate state with the current nautilus_trader version, or start with `load_state=false` if a clean start is acceptable.","Restore from a known-good backup of the streaming/state store."],"exampleFix":"// before\nconfig = TradingNodeConfig(cache=CacheConfig(database=DatabaseConfig(type=\"redis\")), load_state=True)\n\n// after\n# first verify/repair state, or start clean:\nconfig = TradingNodeConfig(cache=CacheConfig(database=DatabaseConfig(type=\"redis\")), load_state=False)","handlingStrategy":"try-catch","validationCode":"# before starting with load_state=True, confirm the backing store is reachable\nimport redis\nr = redis.Redis(host=\"localhost\", port=6379)\nr.ping()","typeGuard":null,"tryCatchPattern":"try:\n    node = TradingNode(config=config)  # load_state=True\n    node.start()\nexcept Exception as e:\n    logging.error(\"State load failed: %s\", e)\n    config.load_state = False  # fall back to a clean start\n    node = TradingNode(config=config)\n    node.start()","preventionTips":["Test state restore against a staging copy of the DB before production restarts.","Back up the cache/state store before upgrading nautilus_trader.","Only enable load_state when a compatible snapshot is known to exist."],"tags":["state-restore","persistence","deserialization","kernel"],"backgroundTag":"database-query-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"}