{"record":{"id":"4c8e47c2b0052b76","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-delete-order-index-command-e","errorCode":null,"errorMessage":"Failed to send delete order index command: {e}","messagePattern":"Failed to send delete order index command: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":575,"sourceCode":"            .map_err(|e| anyhow::anyhow!(\"Failed to send delete order command: {e}\"))?;\n\n        // Delete from all order indexes\n        let index_keys = [\n            INDEX_ORDER_IDS,\n            INDEX_ORDERS,\n            INDEX_ORDERS_OPEN,\n            INDEX_ORDERS_CLOSED,\n            INDEX_ORDERS_EMULATED,\n            INDEX_ORDERS_INFLIGHT,\n        ];\n\n        for index_key in &index_keys {\n            let key = (*index_key).to_string();\n            let payload = vec![order_id_bytes.clone()];\n            let op = DatabaseCommand::new(DatabaseOperation::Delete, key, Some(payload));\n            self.tx\n                .send(op)\n                .map_err(|e| anyhow::anyhow!(\"Failed to send delete order index command: {e}\"))?;\n        }\n\n        // Delete from hash indexes\n        let hash_indexes = [INDEX_ORDER_POSITION, INDEX_ORDER_CLIENT];\n        for index_key in &hash_indexes {\n            let key = (*index_key).to_string();\n            let payload = vec![order_id_bytes.clone()];\n            let op = DatabaseCommand::new(DatabaseOperation::Delete, key, Some(payload));\n            self.tx.send(op).map_err(|e| {\n                anyhow::anyhow!(\"Failed to send delete order hash index command: {e}\")\n            })?;\n        }\n\n        Ok(())\n    }\n\n    /// Delete the given position from the database with full index cleanup.\n    ///","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L557-L593","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = cache.delete_order(&client_order_id) {\n    if e.to_string().contains(\"delete order index command\") {\n        // reconnect cache, then re-run delete_order to finish index cleanup\n    }\n}","preventionTips":["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."],"tags":["rust","redis","channel","index-cleanup"],"backgroundTag":"broken-pipe","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"}