{"record":{"id":"e3cf6088a97d886a","repo":"nautechsystems/nautilus_trader","slug":"load-index-order-position-channel-closed-e","errorCode":null,"errorMessage":"load_index_order_position channel closed: {e}","messagePattern":"load_index_order_position channel closed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":1488,"sourceCode":"            self.encoding(),\n        )\n        .await\n    }\n\n    fn load_index_order_position(&self) -> anyhow::Result<AHashMap<ClientOrderId, PositionId>> {\n        let con = self.database.con.clone();\n        let trader_key = self.database.trader_key.clone();\n        let (tx, rx) = mpsc::channel();\n\n        get_runtime().spawn(async move {\n            let result = DatabaseQueries::load_index_order_position(&con, &trader_key).await;\n            if let Err(e) = tx.send(result) {\n                log::error!(\"Failed to send load_index_order_position result: {e:?}\");\n            }\n        });\n\n        blocking_recv(&rx)\n            .map_err(|e| anyhow::anyhow!(\"load_index_order_position channel closed: {e}\"))?\n    }\n\n    fn load_index_order_client(&self) -> anyhow::Result<AHashMap<ClientOrderId, ClientId>> {\n        let con = self.database.con.clone();\n        let trader_key = self.database.trader_key.clone();\n        let (tx, rx) = mpsc::channel();\n\n        get_runtime().spawn(async move {\n            let result = DatabaseQueries::load_index_order_client(&con, &trader_key).await;\n            if let Err(e) = tx.send(result) {\n                log::error!(\"Failed to send load_index_order_client result: {e:?}\");\n            }\n        });\n\n        blocking_recv(&rx)\n            .map_err(|e| anyhow::anyhow!(\"load_index_order_client channel closed: {e}\"))?\n    }\n","sourceCodeStart":1470,"sourceCodeEnd":1506,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L1470-L1506","documentation":"Loads the (index_order → position) mapping from Redis via a blocking worker thread and an mpsc result channel. This error indicates the channel closed before a result arrived — the worker task was dropped or panicked, so `blocking_recv` returned `RecvError`.","triggerScenarios":"Calling the order/position index load during cache reconstruction when the spawned index-loading task panics (bad payload, missing key structure) or is dropped before sending its result.","commonSituations":"Partially written or manually edited Redis index keys; corrupted msgpack/json data in the index collection; process shutdown mid-load.","solutions":["Look for a preceding log entry ('Failed to send load_index_order_position result' or a panic) to identify the root cause","Inspect the Redis keys under the trader's index_order_position prefix for malformed or missing entries and repair/remove them","Retry the load on a healthy connection","If reproducible, refactor the task to propagate the error through the channel instead of logging it"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify index data shape before load\nlet raw: Option<String> = redis::cmd(\"GET\")\n    .arg(format!(\"{trader_key}:index_order_position\"))\n    .query(&mut con)?;\nassert!(raw.is_some(), \"index_order_position key missing\");","typeGuard":null,"tryCatchPattern":"// Rust\nmatch cache.load_index_order_position() {\n    Ok(index) => index,\n    Err(e) if e.to_string().contains(\"channel closed\") => {\n        log::error!(\"index loader task died: {e:#}\");\n        cache.load_index_order_position()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check for panics or send-failure logs in the worker preceding this error","Repair or delete malformed Redis index keys before loading","Retry the load on a healthy connection","Propagate worker errors through the channel for clearer diagnostics"],"tags":["redis","channel","index","async"],"backgroundTag":"channel-closed","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"}