{"record":{"id":"1e30f8e5124b7c8a","repo":"nautechsystems/nautilus_trader","slug":"load-synthetic-not-implemented-for-postgresql-cach","errorCode":null,"errorMessage":"load_synthetic not implemented for PostgreSQL cache adapter: {instrument_id}","messagePattern":"load_synthetic not implemented for PostgreSQL cache adapter: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":806,"sourceCode":"                        log::error!(\"Failed to send instrument {instrument_id}: {e:?}\");\n                    }\n                }\n                Err(e) => {\n                    log::error!(\"Failed to load instrument {instrument_id}: {e:?}\");\n                    if let Err(e) = tx.send(None) {\n                        log::error!(\"Failed to send None for instrument {instrument_id}: {e:?}\");\n                    }\n                }\n            }\n        });\n        Ok(rx.recv()?)\n    }\n\n    async fn load_synthetic(\n        &self,\n        instrument_id: &InstrumentId,\n    ) -> anyhow::Result<Option<SyntheticInstrument>> {\n        anyhow::bail!(\n            \"load_synthetic not implemented for PostgreSQL cache adapter: {instrument_id}\"\n        )\n    }\n\n    async fn load_account(&self, account_id: &AccountId) -> anyhow::Result<Option<AccountAny>> {\n        let pool = self.pool.clone();\n        let account_id = account_id.to_owned();\n        let (tx, rx) = std::sync::mpsc::channel();\n\n        tokio::spawn(async move {\n            let result = DatabaseQueries::load_account(&pool, &account_id).await;\n            match result {\n                Ok(account) => {\n                    if let Err(e) = tx.send(account) {\n                        log::error!(\"Failed to send account {account_id}: {e:?}\");\n                    }\n                }\n                Err(e) => {","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L788-L824","documentation":"The PostgreSQL cache adapter has not implemented load_synthetic; the method unconditionally fails with the instrument id embedded in the message. The SQL backend stores some cache entities but synthetic instrument definitions are not (yet) persisted there.","triggerScenarios":"Configuring a CacheDatabase with the PostgreSQL adapter and requesting a synthetic instrument via cache.load_synthetic — e.g. a strategy that looks up its synthetic instruments from the cache database on start.","commonSituations":"Migrating a deployment from Redis cache to PostgreSQL cache; strategies using SyntheticInstrument that worked with the Redis adapter; enabling the SQL adapter for a trading config that references synthetics.","solutions":["Do not rely on the cache database for synthetic instruments: construct/load them from the config or local cache instead of via the SQL adapter","Use the Redis cache adapter if synthetics must be persisted to a backing database","Implement load_synthetic in crates/infrastructure/src/sql/cache.rs, persisting synthetic definitions like other instruments"],"exampleFix":"// before\nlet synthetic = cache_db.load_synthetic(&synthetic_id)?; // bails on Postgres\n// after\nlet synthetic = cache.synthetic(&synthetic_id) // resolve from in-memory cache/config\n    .ok_or_else(|| anyhow::anyhow!(\"synthetic {synthetic_id} not configured\"))?;","handlingStrategy":"fallback","validationCode":"// check adapter capability before calling\nfn supports_synthetic_load(db: &dyn CacheDatabase) -> bool { db.as_any().downcast_ref::<PostgresCache>().is_none() }","typeGuard":null,"tryCatchPattern":"match cache_db.load_synthetic(&synthetic_id) {\n    Ok(s) => s,\n    Err(e) if e.to_string().contains(\"not implemented\") => load_synthetic_from_config(&synthetic_id),\n    Err(e) => return Err(e),\n}","preventionTips":["Check which cache entities each adapter supports before choosing SQL vs Redis","Load synthetic instruments from strategy config rather than a SQL cache database","Track adapter feature gaps when upgrading nautilus versions"],"tags":["postgresql","cache","not-implemented","synthetic-instrument"],"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-14T11:17:12.474Z"}