{"record":{"id":"7c17baad7c8c0822","repo":"nautechsystems/nautilus_trader","slug":"delete-order-not-implemented-for-postgresql-cache","errorCode":null,"errorMessage":"delete_order not implemented for PostgreSQL cache adapter: {client_order_id}","messagePattern":"delete_order not implemented for PostgreSQL cache adapter: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":891,"sourceCode":"\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!(\n            \"delete_account_event not implemented for PostgreSQL cache adapter: {account_id}, {event_id}\"\n        )\n    }\n\n    fn add(&self, key: String, value: Bytes) -> anyhow::Result<()> {\n        let query = DatabaseQuery::Add(key, value.into());\n        self.tx\n            .send(query)","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L873-L909","documentation":"Sentinel error in the PostgreSQL cache adapter's delete_order: order deletion is not implemented for the PostgreSQL cache backend, so the operation always fails and reports the client order ID involved.","triggerScenarios":"Calling cache.delete_order (or cache database delete) for a ClientOrderId with the PostgreSQL adapter attached — e.g. purging stale inflight orders or cleanup routines.","commonSituations":"Cache hygiene/cleanup scripts that worked with Redis; deleting emulated or expired orders from persistent cache; test teardown removing orders from a shared SQL cache.","solutions":["Skip order deletion when running against the PostgreSQL adapter; leave records and filter by state instead","Use the Redis adapter if order deletion is required","Implement delete_order in sql/cache.rs (issue the appropriate DELETE against the orders table)"],"exampleFix":"// before\ncache_db.delete_order(&client_order_id)?; // bails on Postgres\n// after\nif supports_order_delete(&cache_db) {\n    cache_db.delete_order(&client_order_id)?;\n} else {\n    log::debug!(\"order deletion unsupported by SQL cache adapter; skipping\");\n}","handlingStrategy":"try-catch","validationCode":"if is_postgres_cache(&cache_db) { /* deletion unsupported — skip */ }","typeGuard":"fn is_postgres_cache(db: &dyn CacheDatabase) -> bool { db.as_any().downcast_ref::<PostgresCache>().is_some() }","tryCatchPattern":"if let Err(e) = cache_db.delete_order(&client_order_id) {\n    if e.to_string().contains(\"not implemented\") {\n        log::debug!(\"skipping order delete (unsupported on SQL adapter)\");\n    } else { return Err(e); }\n}","preventionTips":["Design cleanup jobs per adapter capability","Treat cached orders as append-only on SQL backends","Verify adapter parity before porting Redis cleanup scripts"],"tags":["postgresql","cache","not-implemented","order","delete"],"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"}