{"record":{"id":"191b9ea2cbe09805","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-query-index-order-clients-to-databa","errorCode":null,"errorMessage":"Failed to send query index_order_clients to database message handler: {e}","messagePattern":"Failed to send query index_order_clients to database message handler: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":1243,"sourceCode":"        client_order_id: ClientOrderId,\n        position_id: PositionId,\n    ) -> anyhow::Result<()> {\n        let query = DatabaseQuery::IndexOrderPosition(client_order_id, position_id);\n        self.tx.send(query).map_err(|e| {\n            anyhow::anyhow!(\n                \"Failed to send query index_order_position to database message handler: {e}\"\n            )\n        })\n    }\n\n    fn index_order_clients(&self, claims: &[(ClientOrderId, ClientId)]) -> anyhow::Result<()> {\n        if claims.is_empty() {\n            return Ok(());\n        }\n\n        let query = DatabaseQuery::IndexOrderClients(claims.to_vec());\n        self.tx.send(query).map_err(|e| {\n            anyhow::anyhow!(\n                \"Failed to send query index_order_clients to database message handler: {e}\"\n            )\n        })\n    }\n\n    fn update_actor(\n        &self,\n        actor_id: &ActorId,\n        _state: &AHashMap<String, Bytes>,\n    ) -> anyhow::Result<()> {\n        anyhow::bail!(\"update_actor not implemented for PostgreSQL cache adapter: {actor_id}\")\n    }\n\n    fn update_strategy(\n        &self,\n        strategy_id: &StrategyId,\n        _state: &AHashMap<String, Bytes>,\n    ) -> anyhow::Result<()> {","sourceCodeStart":1225,"sourceCodeEnd":1261,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L1225-L1261","documentation":"index_order_clients batches (ClientOrderId, ClientId) claims into DatabaseQuery::IndexOrderClients and sends them over self.tx to the database message handler; a send failure is wrapped in this error. An empty claims slice returns Ok early, so the only failure is a closed channel — the handler task has been dropped. The mapping is never persisted when this fires.","triggerScenarios":"Calling index_order_clients with a non-empty claims slice after the handler task exited (shutdown, abort, or handler init failure).","commonSituations":"Adapter shutdown racing with execution engine index updates; handler crash from a prior failed query; stale adapter references after reconnect.","solutions":["Confirm the cache handler task is alive before index updates","Rebuild the adapter if it was shut down; do not reuse closed instances","Fix the handler's original failure from logs","Treat this as critical in live trading: order→client mappings lost here affect later lookups"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = cache.index_order_clients(&claims) {\n    tracing::error!(\"order-client indexing failed: {e:#}\");\n    return Err(e.into());\n}","preventionTips":["Never reuse a cache adapter after its handler task has been dropped","Check handler liveness before batch index updates","Investigate any prior handler panic — it closes the channel for all later calls","Order shutdown: engine stops indexing, then adapter drops"],"tags":["rust","channel","database","postgres"],"backgroundTag":"broken-pipe","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}