nautechsystems/nautilus_trader · error

delete_order not implemented for PostgreSQL cache adapter: {

Error message

delete_order not implemented for PostgreSQL cache adapter: {client_order_id}

What it means

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.

Source

Thrown at crates/infrastructure/src/sql/cache.rs:891

    fn load_actor(&self, actor_id: &ActorId) -> anyhow::Result<AHashMap<String, Bytes>> {
        anyhow::bail!("load_actor not implemented for PostgreSQL cache adapter: {actor_id}")
    }

    fn delete_actor(&self, _actor_id: &ActorId) -> anyhow::Result<()> {
        todo!()
    }

    fn load_strategy(&self, strategy_id: &StrategyId) -> anyhow::Result<AHashMap<String, Bytes>> {
        anyhow::bail!("load_strategy not implemented for PostgreSQL cache adapter: {strategy_id}")
    }

    fn delete_strategy(&self, _strategy_id: &StrategyId) -> anyhow::Result<()> {
        todo!()
    }

    fn delete_order(&self, client_order_id: &ClientOrderId) -> anyhow::Result<()> {
        anyhow::bail!(
            "delete_order not implemented for PostgreSQL cache adapter: {client_order_id}"
        )
    }

    fn delete_position(&self, position_id: &PositionId) -> anyhow::Result<()> {
        anyhow::bail!("delete_position not implemented for PostgreSQL cache adapter: {position_id}")
    }

    fn delete_account_event(&self, account_id: &AccountId, event_id: &str) -> anyhow::Result<()> {
        anyhow::bail!(
            "delete_account_event not implemented for PostgreSQL cache adapter: {account_id}, {event_id}"
        )
    }

    fn add(&self, key: String, value: Bytes) -> anyhow::Result<()> {
        let query = DatabaseQuery::Add(key, value.into());
        self.tx
            .send(query)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Skip order deletion when running against the PostgreSQL adapter; leave records and filter by state instead
  2. Use the Redis adapter if order deletion is required
  3. Implement delete_order in sql/cache.rs (issue the appropriate DELETE against the orders table)

Example fix

// before
cache_db.delete_order(&client_order_id)?; // bails on Postgres
// after
if supports_order_delete(&cache_db) {
    cache_db.delete_order(&client_order_id)?;
} else {
    log::debug!("order deletion unsupported by SQL cache adapter; skipping");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if is_postgres_cache(&cache_db) { /* deletion unsupported — skip */ }

Type guard

fn is_postgres_cache(db: &dyn CacheDatabase) -> bool { db.as_any().downcast_ref::<PostgresCache>().is_some() }

Try / catch

if let Err(e) = cache_db.delete_order(&client_order_id) {
    if e.to_string().contains("not implemented") {
        log::debug!("skipping order delete (unsupported on SQL adapter)");
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/7c17baad7c8c0822. Report an issue: GitHub.