{"record":{"id":"192aefd8f5c0293e","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-delete-order-hash-index-command-e","errorCode":null,"errorMessage":"Failed to send delete order hash index command: {e}","messagePattern":"Failed to send delete order hash index command: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":585,"sourceCode":"        ];\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    ///\n    /// # Errors\n    ///\n    /// Returns an error if the command cannot be sent to the background task channel.\n    pub fn delete_position(&self, position_id: &PositionId) -> anyhow::Result<()> {\n        let position_id_bytes = Bytes::from(position_id.to_string());\n\n        // Delete the position itself\n        let key = format!(\"{POSITIONS}{REDIS_DELIMITER}{position_id}\");\n        let op = DatabaseCommand::new(DatabaseOperation::Delete, key, None);\n        self.tx","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L567-L603","documentation":"After set-index cleanup, delete_order removes the order id from hash indexes (order-to-position and order-to-client mappings). This error is the same channel-send failure raised specifically for those hash index delete commands when the writer task's receiver is gone.","triggerScenarios":"Calling delete_order with a dead command-channel receiver, occurring after the order delete and set-index deletes were queued.","commonSituations":"Mid-shutdown deletes, Redis connection loss that killed the writer, or a cache adapter that was constructed but whose command loop exited.","solutions":["Reconnect/restart the cache writer task and retry delete_order.","Ensure deletes happen while the trading node and its cache task are alive.","Investigate why the writer task exited (Redis outage, panic) using earlier log entries.","Audit Redis hash indexes (INDEX_ORDER_POSITION / INDEX_ORDER_CLIENT) for orphaned entries after such a failure."],"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(\"hash index command\") {\n        // reconnect and retry; then clean orphaned hash entries\n    }\n}","preventionTips":["Ensure the writer task is alive before deleting orders.","After a failed delete, verify INDEX_ORDER_POSITION and INDEX_ORDER_CLIENT hashes for orphans.","Avoid issuing cache commands after shutdown has started."],"tags":["rust","redis","channel","hash-index"],"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"}