nautechsystems/nautilus_trader · error
Failed to load quotes: {e}
Error message
Failed to load quotes: {e} What it means
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.
Source
Thrown at crates/infrastructure/src/sql/queries.rs:1332
}
/// Loads all `QuoteTick` entries for `instrument_id` via the provided `pool`.
///
/// # Errors
///
/// Returns an error if the SQL SELECT or deserialization fails.
pub async fn load_quotes(
pool: &PgPool,
instrument_id: &InstrumentId,
) -> anyhow::Result<Vec<QuoteTick>> {
sqlx::query_as::<_, QuoteTickRow>(
r#"SELECT * FROM "quote" WHERE instrument_id = $1 ORDER BY ts_event ASC"#,
)
.bind(instrument_id.to_string())
.fetch_all(pool)
.await
.map(|rows| rows.into_iter().map(|row| row.0).collect())
.map_err(|e| anyhow::anyhow!("Failed to load quotes: {e}"))
}
/// Inserts a `Bar` entry via the provided `pool`.
///
/// # Errors
///
/// Returns an error if the SQL INSERT operation fails.
pub async fn add_bar(pool: &PgPool, bar: &Bar) -> anyhow::Result<()> {
if bar.bar_type.is_composite() {
anyhow::bail!(
"Cannot persist bar with composite bar type {}: the bar table stores only \
the standard form; standardize the bar type before persisting",
bar.bar_type,
);
}
let bar_step = i32::try_from(bar.bar_type.spec().step.get())
.map_err(|e| anyhow::anyhow!("invalid bar step: {e}"))?;View on GitHub (pinned to 18893faf8b)
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
Defensive patterns
Strategy: retry
Validate before calling
sqlx::query("SELECT 1 FROM quote LIMIT 1").fetch_optional(pool).await?; Try / catch
let quotes = load_quotes(&pool, &instrument_id).await
.map_err(|e| { tracing::error!("load_quotes: {e:#}"); e })?; Prevention
- Run migrations on deploy
- Set explicit query timeouts and pool sizes
- Retry transient connection failures
When it happens
Trigger: 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.
Common situations: Migrations skipped in a new deployment; network/auth failures; timeouts on large quote tables; pool contention under concurrent readers.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Error executing statement {sql_statement} with error: {e:?}
- Failed to read verification schema version: {e}
- Failed to read canonical nonce ledger: {e}
- Failed to load account ids: {e}
- Failed to insert into trade table: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/5be04cfdbae81580.
Report an issue: GitHub.