nautechsystems/nautilus_trader · error · anyhow::Error
Failed to commit execution schema migration
Error message
Failed to commit execution schema migration: {e} What it means
Wrapped error from database.rs:3668 raised when committing the execution schema migration transaction fails. All v2 activation DDL executed successfully but PostgreSQL refused the COMMIT, leaving the migration unapplied (transactional rollback semantics apply).
Solutions
- Re-run the migration; nothing was committed, so it is safe to retry from scratch.
- Increase idle_in_transaction_session_timeout or network keepalives if long DDL batches cause disconnects.
- Check PostgreSQL server logs for the commit-time failure reason (connection reset, serialization, read-only).
- Run the migration against the primary node, not a replica, and during a quiet maintenance window.
Defensive patterns
Strategy: retry
Validate before calling
-- preflight: writable primary, sane timeout SHOW transaction_read_only; -- must be off SHOW idle_in_transaction_session_timeout; -- ample for the DDL batch
Try / catch
loop {
match migrate_execution_schema(&pool).await {
Ok(()) => break,
Err(e) if e.to_string().contains("Failed to commit execution schema migration") => {
backoff::sleep().await; // safe: nothing was committed
},
Err(e) => return Err(e),
}
} Prevention
- Run migrations in a maintenance window with a stable connection
- Raise idle_in_transaction_session_timeout for long DDL batches
- Always retry — the commit failure rolled everything back
When it happens
Trigger: Calling transaction.commit() at the end of the v2 migration when the connection to PostgreSQL has been lost, the transaction was already aborted, the transaction is idle-in-transaction timeout-killed, or the database is in read-only/recovery mode.
Common situations: Long-running migration exceeds idle_in_transaction_session_timeout; network interruption between the last DDL and commit; database failover or maintenance restart during the migration window; running against a hot-standby replica.
Related errors
- Cannot safely migrate
- Execution payload rollback left
- Failed to activate execution schema version 2
- Failed to commit signed transaction
- Failed to install verification schema
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/6ce57d9c96b10fc1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/blockchain/src/cache/database.rs:3668
"
INSERT INTO execution_schema_version (component, version)
VALUES ('evm_execution', 2)
ON CONFLICT (component) DO UPDATE SET version = EXCLUDED.version
WHERE execution_schema_version.version <= EXCLUDED.version
",
] {
sqlx::query(statement)
.execute(&mut *transaction)
.await
.map_err(|e| {
anyhow::anyhow!("Failed to activate execution schema version 2: {e}")
})?;
}
transaction
.commit()
.await
.map_err(|e| anyhow::anyhow!("Failed to commit execution schema migration: {e}"))?;
Ok(())
}
/// Loads the durable finalized-header and nonce position when verification is active.
pub(crate) async fn load_execution_verification_position(
&self,
chain_id: u32,
wallet_address: &str,
manifest_version: &str,
manifest_digest: &str,
) -> anyhow::Result<Option<ExecutionVerificationPosition>> {
let installed = sqlx::query_scalar::<_, i16>(
"SELECT version FROM execution_schema_version \
WHERE component = 'evm_execution_verification'",
)
.fetch_optional(&self.pool)
.awaitView on GitHub (pinned to 18893faf8b)