{"record":{"id":"5be04cfdbae81580","repo":"nautechsystems/nautilus_trader","slug":"failed-to-load-quotes-e","errorCode":null,"errorMessage":"Failed to load quotes: {e}","messagePattern":"Failed to load quotes: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/queries.rs","lineNumber":1332,"sourceCode":"    }\n\n    /// Loads all `QuoteTick` entries for `instrument_id` via the provided `pool`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the SQL SELECT or deserialization fails.\n    pub async fn load_quotes(\n        pool: &PgPool,\n        instrument_id: &InstrumentId,\n    ) -> anyhow::Result<Vec<QuoteTick>> {\n        sqlx::query_as::<_, QuoteTickRow>(\n            r#\"SELECT * FROM \"quote\" WHERE instrument_id = $1 ORDER BY ts_event ASC\"#,\n        )\n        .bind(instrument_id.to_string())\n        .fetch_all(pool)\n        .await\n        .map(|rows| rows.into_iter().map(|row| row.0).collect())\n        .map_err(|e| anyhow::anyhow!(\"Failed to load quotes: {e}\"))\n    }\n\n    /// Inserts a `Bar` entry via the provided `pool`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the SQL INSERT operation fails.\n    pub async fn add_bar(pool: &PgPool, bar: &Bar) -> anyhow::Result<()> {\n        if bar.bar_type.is_composite() {\n            anyhow::bail!(\n                \"Cannot persist bar with composite bar type {}: the bar table stores only \\\n                 the standard form; standardize the bar type before persisting\",\n                bar.bar_type,\n            );\n        }\n\n        let bar_step = i32::try_from(bar.bar_type.spec().step.get())\n            .map_err(|e| anyhow::anyhow!(\"invalid bar step: {e}\"))?;","sourceCodeStart":1314,"sourceCodeEnd":1350,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/queries.rs#L1314-L1350","documentation":"This error wraps sqlx failures from `SELECT * FROM \"quote\" WHERE instrument_id = $1 ORDER BY ts_event ASC` in `load_quotes`. Quote rows could not be retrieved from PostgreSQL; the underlying sqlx error is embedded in the message.","triggerScenarios":"Calling `load_quotes(pool, instrument_id)` when the DB is unreachable, the `quote` table does not exist, the query times out, or the pool cannot provide a connection.","commonSituations":"Migrations skipped in a new deployment; network/auth failures; timeouts on large quote tables; pool contention under concurrent readers.","solutions":["Apply migrations so the `quote` table exists","Validate connectivity and pool configuration (DSN, timeouts)","Inspect the wrapped sqlx error and fix the root cause","Retry transient failures with backoff"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"sqlx::query(\"SELECT 1 FROM quote LIMIT 1\").fetch_optional(pool).await?;","typeGuard":null,"tryCatchPattern":"let quotes = load_quotes(&pool, &instrument_id).await\n    .map_err(|e| { tracing::error!(\"load_quotes: {e:#}\"); e })?;","preventionTips":["Run migrations on deploy","Set explicit query timeouts and pool sizes","Retry transient connection failures"],"tags":["database","sql","postgres"],"backgroundTag":"database-query-failed","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"}