{"record":{"id":"792db46c47deb8d2","repo":"nautechsystems/nautilus_trader","slug":"load-strategy-not-implemented-for-postgresql-cache","errorCode":null,"errorMessage":"load_strategy not implemented for PostgreSQL cache adapter: {strategy_id}","messagePattern":"load_strategy not implemented for PostgreSQL cache adapter: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":883,"sourceCode":"        tokio::spawn(async move {\n            let result = DatabaseQueries::load_position(&pool, &position_id).await;\n            if let Err(e) = tx.send(result) {\n                log::error!(\"Failed to send position {position_id}: {e:?}\");\n            }\n        });\n        rx.recv()?\n    }\n\n    fn load_actor(&self, actor_id: &ActorId) -> anyhow::Result<AHashMap<String, Bytes>> {\n        anyhow::bail!(\"load_actor not implemented for PostgreSQL cache adapter: {actor_id}\")\n    }\n\n    fn delete_actor(&self, _actor_id: &ActorId) -> anyhow::Result<()> {\n        todo!()\n    }\n\n    fn load_strategy(&self, strategy_id: &StrategyId) -> anyhow::Result<AHashMap<String, Bytes>> {\n        anyhow::bail!(\"load_strategy not implemented for PostgreSQL cache adapter: {strategy_id}\")\n    }\n\n    fn delete_strategy(&self, _strategy_id: &StrategyId) -> anyhow::Result<()> {\n        todo!()\n    }\n\n    fn delete_order(&self, client_order_id: &ClientOrderId) -> anyhow::Result<()> {\n        anyhow::bail!(\n            \"delete_order not implemented for PostgreSQL cache adapter: {client_order_id}\"\n        )\n    }\n\n    fn delete_position(&self, position_id: &PositionId) -> anyhow::Result<()> {\n        anyhow::bail!(\"delete_position not implemented for PostgreSQL cache adapter: {position_id}\")\n    }\n\n    fn delete_account_event(&self, account_id: &AccountId, event_id: &str) -> anyhow::Result<()> {\n        anyhow::bail!(","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L865-L901","documentation":"Unimplemented trait method in the PostgreSQL cache adapter: strategy state loading is not implemented, so load_strategy always bails with the requested strategy_id (rather than panicking via todo!()).","triggerScenarios":"Loading strategy state (StrategyId) from a PostgreSQL cache database at strategy start with load_state enabled; restore tooling calling load_strategy on the SQL adapter.","commonSituations":"Switching deployments from Redis cache to PostgreSQL; expecting strategy checkpoint/restore to work across restarts with the SQL adapter.","solutions":["Use the Redis cache adapter for strategy state persistence","Disable strategy load_state when using the PostgreSQL adapter","Implement load_strategy in sql/cache.rs (persist strategy state like other string-blob entities)"],"exampleFix":"// before\nlet state = cache_db.load_strategy(&strategy_id)?; // bails on Postgres\n// after\nmatch cache_db.load_strategy(&strategy_id) {\n    Ok(state) => state,\n    Err(e) if e.to_string().contains(\"not implemented\") => { log::warn!(\"strategy state unavailable with SQL adapter\"); Default::default() }\n    Err(e) => return Err(e),\n}","handlingStrategy":"fallback","validationCode":"if is_postgres_cache(&cache_db) { /* skip strategy state load */ }","typeGuard":"fn is_postgres_cache(db: &dyn CacheDatabase) -> bool { db.as_any().downcast_ref::<PostgresCache>().is_some() }","tryCatchPattern":"match cache_db.load_strategy(&strategy_id) {\n    Ok(state) => state,\n    Err(e) if e.to_string().contains(\"not implemented\") => { log::warn!(\"no persisted strategy state with SQL adapter\"); AHashMap::new() }\n    Err(e) => return Err(e),\n}","preventionTips":["Persist strategy state via Redis if checkpoint/restore matters","Gate load_state config on adapter type","Test strategy restarts against the exact adapter used in production"],"tags":["postgresql","cache","not-implemented","strategy"],"backgroundTag":"method-not-implemented","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"}