nautechsystems/nautilus_trader · error
Failed to send delete order index command
Error message
Failed to send delete order index command: {e} What it means
When deleting an order, the cache also removes the order id from set indexes (order ids, all orders, open/closed orders, etc.). This error means sending one of those index Delete commands on the internal channel failed because the receiving writer task is no longer available.
Solutions
- Restore the cache connection / restart the Redis writer task, then re-run delete_order to redo index cleanup.
- Verify the node is still running when delete_order is called; avoid deletes after shutdown begins.
- Check for prior errors that terminated the writer task (connection loss, task panic) and fix that root cause.
- Manually verify index sets in Redis for stale order ids if cleanup failed mid-way.
Defensive patterns
Strategy: retry
Try / catch
if let Err(e) = cache.delete_order(&client_order_id) {
if e.to_string().contains("delete order index command") {
// reconnect cache, then re-run delete_order to finish index cleanup
}
} Prevention
- Keep cache mutations within a healthy, connected session.
- Re-run delete_order after any channel failure to complete index cleanup.
- Periodically audit Redis index sets for stale order ids.
When it happens
Trigger: Calling delete_order when the Redis command-channel receiver has been dropped — the order itself may have been queued but index cleanup could not be sent.
Common situations: Same as the main delete-order send failure: shutdown ordering issues, a crashed writer task after Redis connectivity loss, or use of a cache adapter whose background task exited.
Related errors
- Failed to send delete position index command
- Failed to send delete order command
- Failed to send delete order hash index command
- Failed to send delete position command
- Failed to send to channel
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/4c8e47c2b0052b76.
Report an issue: GitHub.
Appendix: source
Thrown at crates/infrastructure/src/redis/cache.rs:575
.map_err(|e| anyhow::anyhow!("Failed to send delete order command: {e}"))?;
// Delete from all order indexes
let index_keys = [
INDEX_ORDER_IDS,
INDEX_ORDERS,
INDEX_ORDERS_OPEN,
INDEX_ORDERS_CLOSED,
INDEX_ORDERS_EMULATED,
INDEX_ORDERS_INFLIGHT,
];
for index_key in &index_keys {
let key = (*index_key).to_string();
let payload = vec![order_id_bytes.clone()];
let op = DatabaseCommand::new(DatabaseOperation::Delete, key, Some(payload));
self.tx
.send(op)
.map_err(|e| anyhow::anyhow!("Failed to send delete order index command: {e}"))?;
}
// Delete from hash indexes
let hash_indexes = [INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT];
for index_key in &hash_indexes {
let key = (*index_key).to_string();
let payload = vec![order_id_bytes.clone()];
let op = DatabaseCommand::new(DatabaseOperation::Delete, key, Some(payload));
self.tx.send(op).map_err(|e| {
anyhow::anyhow!("Failed to send delete order hash index command: {e}")
})?;
}
Ok(())
}
/// Delete the given position from the database with full index cleanup.
///View on GitHub (pinned to 18893faf8b)