nautechsystems/nautilus_trader · error

No persisted order events found for {client_order_id}

Error message

No persisted order events found for {client_order_id}

What it means

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.

Source

Thrown at crates/infrastructure/src/sql/queries.rs:1402

            .await
            .map_err(|e| anyhow::anyhow!("Failed to persist execution client {client_id}: {e}"))?;

            let result = sqlx::query(
                r#"
                UPDATE "order_event"
                SET client_id = $2
                WHERE client_order_id = $1
                  AND (client_id IS NULL OR client_id = $2)
            "#,
            )
            .bind(client_order_id.to_string())
            .bind(client_id.to_string())
            .execute(&mut *transaction)
            .await
            .map_err(|e| anyhow::anyhow!("Failed to index order client origin: {e}"))?;

            if result.rows_affected() == 0 {
                anyhow::bail!("No persisted order events found for {client_order_id}");
            }
        }

        transaction
            .commit()
            .await
            .map_err(|e| anyhow::anyhow!("Failed to commit order client origins: {e}"))
    }

    /// Inserts or updates an order ID to position ID index entry via the provided `pool`.
    ///
    /// # Errors
    ///
    /// Returns an error if the SQL INSERT or UPDATE operation fails.
    pub async fn index_order_position(
        pool: &PgPool,
        client_order_id: ClientOrderId,
        position_id: PositionId,

View on GitHub (pinned to d1527c24af)

Solutions

  1. Verify rows exist first: SELECT count(*) FROM order_event WHERE client_order_id = '...';
  2. Point the cache configuration at the correct Postgres database and verify credentials/host.
  3. Remove stale or wrong order IDs from the strategy's external_order_claims list.
  4. Run the node once without claims so the orders are persisted, then enable the claims on the next start.
Defensive patterns

Strategy: validation

Validate before calling

-- Confirm each claimed order has persisted events before enabling claims
SELECT client_order_id, count(*) AS events
FROM order_event
WHERE client_order_id = ANY($1)
GROUP BY client_order_id;
-- Every claimed id must show events > 0

Try / catch

if let Err(e) = node.run().await {
    if e.to_string().contains("No persisted order events found") {
        log::error!("claim references unknown order; check DB connection and claim list");
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@d1527c24af (2026-08-21). Data as JSON: /api/errors/50acd0dbd6259689. Report an issue: GitHub.