{"record":{"id":"fc227994dc3684e4","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-delete-position-index-command-e","errorCode":null,"errorMessage":"Failed to send delete position index command: {e}","messagePattern":"Failed to send delete position index command: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":619,"sourceCode":"        let key = format!(\"{POSITIONS}{REDIS_DELIMITER}{position_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 position command: {e}\"))?;\n\n        // Delete from all position indexes\n        let index_keys = [\n            INDEX_POSITIONS,\n            INDEX_POSITIONS_OPEN,\n            INDEX_POSITIONS_CLOSED,\n        ];\n\n        for index_key in &index_keys {\n            let key = (*index_key).to_string();\n            let payload = vec![position_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 position index command: {e}\")\n            })?;\n        }\n\n        Ok(())\n    }\n\n    /// Delete the given account event from the database.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the command cannot be sent to the background task channel.\n    pub fn delete_account_event(\n        &self,\n        account_id: &AccountId,\n        event_id: &str,\n    ) -> anyhow::Result<()> {\n        log::warn!(\n            \"Deleting account events currently a no-op (pending redesign), {account_id}: {event_id}\"","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L601-L637","documentation":"After deleting the position record, delete_position removes the position id from set indexes (positions, open positions, closed positions). This error indicates the channel send for one of those index delete commands failed because the writer task's receiver is gone.","triggerScenarios":"Calling delete_position with a dead command channel — raised during the index-cleanup loop after the position delete was queued.","commonSituations":"Shutdown-time cleanup, writer task death from Redis connectivity loss, or misuse of a cache adapter outside the live node lifecycle.","solutions":["Restore the writer task / connection and retry delete_position so indexes are cleaned.","Keep all cache mutations inside the active node lifecycle.","Diagnose the original cause of the writer task exit from earlier logs.","Check Redis position index sets for stale ids if a partial delete occurred."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = cache.delete_position(&position_id) {\n    if e.to_string().contains(\"delete position index command\") {\n        // reconnect cache and re-run delete_position to finish index cleanup\n    }\n}","preventionTips":["Retry failed position deletes after restoring the connection.","Audit INDEX_POSITIONS / OPEN / CLOSED sets for stale ids after failures.","Keep deletes inside the live node lifecycle."],"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"}