{"record":{"id":"d20aab45ef8f32a8","repo":"nautechsystems/nautilus_trader","slug":"load-actor-not-implemented-for-postgresql-cache-ad","errorCode":null,"errorMessage":"load_actor not implemented for PostgreSQL cache adapter: {actor_id}","messagePattern":"load_actor not implemented for PostgreSQL cache adapter: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":875,"sourceCode":"        Ok(rx.recv()?)\n    }\n\n    async fn load_position(&self, position_id: &PositionId) -> anyhow::Result<Option<Position>> {\n        let pool = self.pool.clone();\n        let position_id = position_id.to_owned();\n        let (tx, rx) = std::sync::mpsc::channel();\n\n        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        )","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L857-L893","documentation":"The PostgreSQL cache adapter does not implement load_actor; calling it always fails. Actor state blobs are not persisted to/read from the SQL backend, so loading an actor's cached state through this adapter is unsupported.","triggerScenarios":"Starting actors with `load_state`/state persistence configured against a PostgreSQL cache database; calling cache.load_actor (or the sync wrapper shown) for any ActorId with the SQL adapter attached.","commonSituations":"Moving actor state persistence from Redis to Postgres; enabling a cache database in config and expecting actor state to survive restarts; snapshot restore tooling.","solutions":["Persist actor state via the Redis cache adapter, which implements actor load/save","Do not configure actor state persistence when using the PostgreSQL adapter; keep actor state in-memory or file-based","Implement load_actor in sql/cache.rs if SQL-backed actor state is required"],"exampleFix":"// before\nlet state = cache_db.load_actor(&actor_id)?; // bails on Postgres\n// after\nif cache_db.is_actor_backed() { // e.g. check adapter kind before use\n    let state = cache_db.load_actor(&actor_id)?;\n}","handlingStrategy":"fallback","validationCode":"if is_postgres_cache(&cache_db) { /* do not call load_actor */ }","typeGuard":"fn is_postgres_cache(db: &dyn CacheDatabase) -> bool { db.as_any().downcast_ref::<PostgresCache>().is_some() }","tryCatchPattern":"match cache_db.load_actor(&actor_id) {\n    Ok(state) => state,\n    Err(e) if e.to_string().contains(\"not implemented\") => AHashMap::new(), // start with default state\n    Err(e) => return Err(e),\n}","preventionTips":["Use the Redis adapter when actor state persistence is required","Only enable load_state for actors when the configured adapter supports it","Document adapter capability matrix for your deployment"],"tags":["postgresql","cache","not-implemented","actor"],"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"}