nautechsystems/nautilus_trader · error · anyhow::Error

Failed to commit verification migration: {e}

Error message

Failed to commit verification migration: {e}

What it means

Thrown when committing the transaction that installed the verification schema fails. All DDL and evidence inserts succeeded locally, but Postgres refused COMMIT — typically because the connection died, the transaction was aborted by another error, or a serialization/deadlock was detected at commit time.

Source

Thrown at crates/adapters/blockchain/src/cache/database.rs:4605

                .map_err(|e| anyhow::anyhow!("Failed to activate verification schema: {e}"))?;
        }
        sqlx::query(
            "
            INSERT INTO execution_schema_version (component, version)
            VALUES ('evm_execution_verification', $1)
            ON CONFLICT (component) DO UPDATE SET version = EXCLUDED.version
            WHERE execution_schema_version.version <= EXCLUDED.version
            ",
        )
        .bind(VERIFICATION_SCHEMA_VERSION)
        .execute(&mut *transaction)
        .await
        .map_err(|e| anyhow::anyhow!("Failed to activate verification schema: {e}"))?;

        transaction
            .commit()
            .await
            .map_err(|e| anyhow::anyhow!("Failed to commit verification migration: {e}"))?;
        Ok(())
    }

    /// Activates or resumes protected signed-transaction storage for this database.
    pub(crate) async fn ensure_execution_payload_storage(
        &self,
        keys: &PayloadKeySet,
    ) -> anyhow::Result<()> {
        let marker = self.execution_payload_marker().await?;
        match marker {
            None => self.activate_execution_payload_storage(keys).await?,
            Some(version) => anyhow::ensure!(
                version == EXECUTION_PAYLOAD_PROTOCOL_VERSION,
                "Execution payload protection version {version} is newer than supported version {EXECUTION_PAYLOAD_PROTOCOL_VERSION}"
            ),
        }

        loop {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Check Postgres logs for why the commit failed (backend termination, deadlock, timeout)
  2. Increase `idle_in_transaction_session_timeout` or speed up bootstrap if migrations are slow
  3. Retry the bootstrap — the migration is transactional so nothing was partially applied
  4. Verify network stability between the node and Postgres

Example fix

// before: bootstrap killed by idle-in-transaction timeout
// postgresql.conf: idle_in_transaction_session_timeout = '10s'
// after
// postgresql.conf: idle_in_transaction_session_timeout = '5min'
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: confirm the connection is healthy and timeouts allow a long transaction
sqlx::query("SELECT 1").execute(&pool).await?;
// ensure idle_in_transaction_session_timeout is generous
let t: Option<String> = sqlx::query_scalar("SHOW idle_in_transaction_session_timeout").fetch_one(&pool).await?;

Try / catch

for attempt in 0..3 {
    match db.ensure_execution_verification_schema().await {
        Err(e) if e.to_string().contains("Failed to commit verification migration") && attempt < 2 => {
            tokio::time::sleep(Duration::from_secs(2u64 << attempt)).await; continue; // transactional: safe to retry
        }
        other => { other?; break; }
    }
}

Prevention

When it happens

Trigger: `transaction.commit()` at the end of `ensure_execution_verification_schema` returns an error: network disconnect between statement execution and commit, Postgres terminating the backend (idle-in-transaction timeout, admin cancel), or the transaction already aborted by a prior statement error not surfaced earlier.

Common situations: Long-running bootstrap exceeding `idle_in_transaction_session_timeout`; a failover or connection-pool eviction during startup; a concurrent process dropping a table that the transaction touched, causing commit-time conflict.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/b2f119527e0f34e8. Report an issue: GitHub.