{"record":{"id":"a57f94c2ef4034cb","repo":"nautechsystems/nautilus_trader","slug":"delete-account-event-not-implemented-for-postgresq","errorCode":null,"errorMessage":"delete_account_event not implemented for PostgreSQL cache adapter: {account_id}, {event_id}","messagePattern":"delete_account_event not implemented for PostgreSQL cache adapter: (.+?), (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":901,"sourceCode":"        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)\n            .map_err(|e| anyhow::anyhow!(\"Failed to send query to database message handler: {e}\"))\n    }\n\n    fn add_currency(&self, currency: &Currency) -> anyhow::Result<()> {\n        let query = DatabaseQuery::AddCurrency(*currency);\n        self.tx.send(query).map_err(|e| {\n            anyhow::anyhow!(\"Failed to query add_currency to database message handler: {e}\")\n        })\n    }\n","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L883-L919","documentation":"The PostgreSQL cache adapter does not implement delete_account_event; the call always fails, naming both the account id and event id. Removing individual account events from the SQL backend is unsupported.","triggerScenarios":"Calling delete_account_event(account_id, event_id) on a PostgreSQL cache database — e.g. correcting a bad account event or reconciliation cleanup.","commonSituations":"Data-repair scripts that assumed Redis parity; removing duplicated account state events; compliance-driven deletions on a Postgres-backed cache.","solutions":["Perform the deletion directly in SQL out-of-band if truly required (with care for referential integrity)","Use the Redis adapter where account event deletion is supported","Implement delete_account_event in sql/cache.rs"],"exampleFix":"// before\ncache_db.delete_account_event(&account_id, &event_id)?; // bails on Postgres\n// after\n// handle explicitly:\nlog::warn!(\"account event deletion not supported by SQL cache adapter; event {event_id} retained\");","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_account_event(&account_id, &event_id) {\n    if e.to_string().contains(\"not implemented\") {\n        log::warn!(\"account event {event_id} not deleted (unsupported on SQL adapter)\");\n    } else { return Err(e); }\n}","preventionTips":["Handle account-event corrections at the database level with an audited migration","Avoid per-event deletion flows on SQL-backed caches","Review adapter support before building data-repair tooling"],"tags":["postgresql","cache","not-implemented","account","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"}