nautechsystems/nautilus_trader · error · anyhow::Error
Failed to get pool event sync state: {e}
Error message
Failed to get pool event sync state: {e} What it means
Wraps a sqlx error from the SELECT that fetches the pool event sync state row (version and last full sync block). This drives incremental event syncing; failing here aborts determining the pool's event sync progress. An absent row is handled gracefully with PoolEventSyncState::default().
Source
Thrown at crates/adapters/blockchain/src/cache/database.rs:1575
chain_id: u32,
dex: &DexType,
pool_identifier: &PoolIdentifier,
) -> anyhow::Result<PoolEventSyncState> {
let pool_state = sqlx::query_as::<_, (i32, Option<i64>)>(
"
SELECT event_sync_version, last_full_sync_block_number
FROM pool
WHERE chain_id = $1
AND dex_name = $2
AND pool_identifier = $3
",
)
.bind(chain_id as i32)
.bind(dex.to_string())
.bind(pool_identifier.as_ref())
.fetch_optional(&self.pool)
.await
.map_err(|e| anyhow::anyhow!("Failed to get pool event sync state: {e}"))?;
let Some((version, last_full_sync_block)) = pool_state else {
return Ok(PoolEventSyncState::default());
};
let family_blocks = sqlx::query_as::<_, (String, i64)>(
"
SELECT event_family, last_full_sync_block_number
FROM pool_event_sync
WHERE chain_id = $1
AND dex_name = $2
AND pool_identifier = $3
ORDER BY event_family
",
)
.bind(chain_id as i32)
.bind(dex.to_string())
.bind(pool_identifier.as_ref())View on GitHub (pinned to 18893faf8b)
Solutions
- Run migrations to ensure the pool event sync state table exists
- Check connectivity and connection-pool health
- Retry the read; it is a pure lookup
- Inspect the wrapped sqlx error to distinguish missing-table vs connection errors
Defensive patterns
Strategy: fallback
Validate before calling
sqlx::query("SELECT 1 FROM pool_event_sync_state LIMIT 1").fetch_optional(&pool).await?; Try / catch
let state = get_pool_event_sync_state(chain_id, dex, pool_id)
.await
.unwrap_or_else(|e| { tracing::warn!("sync state read failed: {e}"); PoolEventSyncState::default() }); Prevention
- Migrate schema before event indexing
- Retry reads on transient DB errors
- Monitor pool health metrics
When it happens
Trigger: Calling `get_pool_event_sync_state(chain_id, dex, pool_identifier)` when the connection is broken, the event sync state table does not exist, or the server returns an error (timeout, lock, etc.).
Common situations: Schema migrations for the event sync state table not applied; database restart during event indexing; connection pool saturation.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- Failed to get pool event-family checkpoints: {e}
- Failed to get dex last synced block: {e}
- Failed to get pool last synced block: {e}
- Failed to get table last block for {table_name}: {e}
- Failed to validate finalized header ledger: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/ba7af08cd5b2148c.
Report an issue: GitHub.