nautechsystems/nautilus_trader · error · anyhow::Error
Failed to update pool last synced block: {e}
Error message
Failed to update pool last synced block: {e} What it means
Wraps a sqlx error from the UPDATE that persists the last synced block for a specific pool of a DEX. This checkpoint lets the indexer resume per-pool event syncing. Failure means the pool's sync progress was not durably recorded.
Source
Thrown at crates/adapters/blockchain/src/cache/database.rs:1493
block_number: u64,
) -> anyhow::Result<()> {
sqlx::query(
"
UPDATE pool
SET last_full_sync_block_number = $4
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())
.bind(block_number as i64)
.execute(&self.pool)
.await
.map(|_| ())
.map_err(|e| anyhow::anyhow!("Failed to update pool last synced block: {e}"))
}
/// Retrieves the saved checkpoint block number from the last completed pool synchronization for a specific DEX.
///
/// # Errors
///
/// Returns an error if the database query fails.
pub async fn get_dex_last_synced_block(
&self,
chain_id: u32,
dex: &DexType,
) -> anyhow::Result<Option<u64>> {
let result = sqlx::query_as::<_, (Option<i64>,)>(
"
SELECT
last_full_sync_pools_block_number
FROM dex
WHERE chain_id = $1View on GitHub (pinned to 18893faf8b)
Solutions
- Apply pending migrations so the pool checkpoint table exists
- Verify the pool identifier matches how the pool was registered (checksummed vs lowercase address)
- Inspect the sqlx error for constraint violations and ensure the parent dex/pool row exists first
- Check DB connectivity and retry; transient errors are common during long sync runs
Defensive patterns
Strategy: retry
Validate before calling
// Verify pool row exists before checkpointing
let exists = sqlx::query("SELECT 1 FROM pools WHERE identifier = $1").bind(pool_identifier).fetch_optional(&pool).await?; Try / catch
if let Err(e) = update_pool_last_synced_block(chain_id, dex, pool_id, block).await {
tracing::error!("pool checkpoint write failed: {e}");
return Err(e);
} Prevention
- Register pools before writing their checkpoints
- Normalize pool identifiers (lowercase addresses) consistently
- Ensure migrations run before indexing starts
When it happens
Trigger: Calling `update_pool_last_synced_block(chain_id, dex, pool_identifier, block_number)` when the pool connection fails, the row/table does not exist because migrations are missing, or a constraint (e.g. FK to a dex/pool table) is violated.
Common situations: Migrations not applied on a new deployment; database failover during indexing; writing pool checkpoints for a pool not yet registered in the database.
Related errors
- Failed to update dex last synced block: {e}
- Failed to get dex last synced block: {e}
- Failed to get pool last synced block: {e}
- Failed to update {event_family} pool event-family checkpoint
- Failed to finalize pool event sync progress: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/57cc168da243f700.
Report an issue: GitHub.