{"record":{"id":"41522288e2cd471b","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-delete-order-command-e","errorCode":null,"errorMessage":"Failed to send delete order command: {e}","messagePattern":"Failed to send delete order command: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":557,"sourceCode":"            Ok(()) => Ok(()),\n            Err(e) => anyhow::bail!(\"{FAILED_TX_CHANNEL}: {e}\"),\n        }\n    }\n\n    /// Delete the given order from the database with full index cleanup.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the command cannot be sent to the background task channel.\n    pub fn delete_order(&self, client_order_id: &ClientOrderId) -> anyhow::Result<()> {\n        let order_id_bytes = Bytes::from(client_order_id.to_string());\n\n        // Delete the order itself\n        let key = format!(\"{ORDERS}{REDIS_DELIMITER}{client_order_id}\");\n        let op = DatabaseCommand::new(DatabaseOperation::Delete, key, None);\n        self.tx\n            .send(op)\n            .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}\"))?;","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L539-L575","documentation":"delete_order queues a Delete command for the order record on an internal mpsc channel to the Redis writer task. This error means the channel send failed — the receiving task is gone (dropped its receiver), so no delete command can be delivered.","triggerScenarios":"Calling delete_order (or py_delete_order) after the Redis writer task that owns the receiving end of the command channel has been shut down or dropped.","commonSituations":"Deleting orders during or after node shutdown, after a database connection failure killed the writer task, or calling into a RedisCache whose background task was never started / already stopped.","solutions":["Ensure the cache database connection is established and healthy before deleting orders; reconnect the cache if the writer task died.","Do not call delete_order after cache shutdown / node teardown — check the node lifecycle.","Check logs for earlier Redis connection errors that caused the writer task to exit, and fix the root connection issue.","Recreate or restart the RedisCache adapter so a live receiver exists, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match cache.delete_order(&client_order_id) {\n    Err(e) if e.to_string().contains(\"Failed to send delete order command\") => {\n        // writer task gone: reconnect cache or defer delete until node restarted\n    }\n    result => result?,\n}","preventionTips":["Only call delete_order while the trading node and cache writer task are running.","Handle cache disconnect events before issuing further cache mutations.","Monitor Redis connectivity; reconnect before retrying deletes."],"tags":["rust","redis","channel","shutdown"],"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"}