{"record":{"id":"50acd0dbd6259689","repo":"nautechsystems/nautilus_trader","slug":"no-persisted-order-events-found-for-client-order","errorCode":null,"errorMessage":"No persisted order events found for {client_order_id}","messagePattern":"No persisted order events found for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/queries.rs","lineNumber":1402,"sourceCode":"            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to persist execution client {client_id}: {e}\"))?;\n\n            let result = sqlx::query(\n                r#\"\n                UPDATE \"order_event\"\n                SET client_id = $2\n                WHERE client_order_id = $1\n                  AND (client_id IS NULL OR client_id = $2)\n            \"#,\n            )\n            .bind(client_order_id.to_string())\n            .bind(client_id.to_string())\n            .execute(&mut *transaction)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to index order client origin: {e}\"))?;\n\n            if result.rows_affected() == 0 {\n                anyhow::bail!(\"No persisted order events found for {client_order_id}\");\n            }\n        }\n\n        transaction\n            .commit()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to commit order client origins: {e}\"))\n    }\n\n    /// Inserts or updates an order ID to position ID index entry via the provided `pool`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the SQL INSERT or UPDATE operation fails.\n    pub async fn index_order_position(\n        pool: &PgPool,\n        client_order_id: ClientOrderId,\n        position_id: PositionId,","sourceCodeStart":1384,"sourceCodeEnd":1420,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/d1527c24afdf475115785557f89a55c3e336c51f/crates/infrastructure/src/sql/queries.rs#L1384-L1420","documentation":"In the same index_order_clients transaction (crates/infrastructure/src/sql/queries.rs:1391), an UPDATE sets client_id on order_event rows matching the claimed client_order_id, guarded by (client_id IS NULL OR client_id = $2). rows_affected() == 0 means no order_event rows exist for that client_order_id at all, so the claim would silently do nothing; the adapter bails instead and the whole claim batch transaction rolls back.","triggerScenarios":"External order claims referencing a client_order_id with zero rows in order_event: a fresh or empty Postgres cache database, events persisted under a different database or trader namespace, a mistyped order ID in the claim list, or events purged by retention.","commonSituations":"Enabling external_order_claims copied from another environment against a database that never persisted those orders; wrong Postgres connection string (host/db/schema) so the adapter sees an empty table; claiming order IDs that exist on the venue but were never recorded locally.","solutions":["Verify rows exist first: SELECT count(*) FROM order_event WHERE client_order_id = '...';","Point the cache configuration at the correct Postgres database and verify credentials/host.","Remove stale or wrong order IDs from the strategy's external_order_claims list.","Run the node once without claims so the orders are persisted, then enable the claims on the next start."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"-- Confirm each claimed order has persisted events before enabling claims\nSELECT client_order_id, count(*) AS events\nFROM order_event\nWHERE client_order_id = ANY($1)\nGROUP BY client_order_id;\n-- Every claimed id must show events > 0","typeGuard":null,"tryCatchPattern":"if let Err(e) = node.run().await {\n    if e.to_string().contains(\"No persisted order events found\") {\n        log::error!(\"claim references unknown order; check DB connection and claim list\");\n    }\n}","preventionTips":["Point the cache config at the same Postgres instance/db that persisted the orders.","Remove order IDs from external_order_claims that were copied from another environment.","Run once without claims so orders persist, then enable claims."],"tags":["postgres","cache","external-order-claims","missing-data"],"backgroundTag":"record-not-found","analyzedSha":"d1527c24afdf475115785557f89a55c3e336c51f","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}