nautechsystems/nautilus_trader · error · anyhow::Error
Failed to activate execution schema version 2: {e}
Error message
Failed to activate execution schema version 2: {e} What it means
Wrapped sqlx error emitted in database.rs:3661 when one of the DDL statements that activates execution schema version 2 fails to execute inside the migration transaction. The statement batch installs fence triggers (blocking legacy writes), an append-only trigger on transitions, and upserts the schema version row. If any single statement fails, the whole migration transaction aborts.
Source
Thrown at crates/adapters/blockchain/src/cache/database.rs:3661
",
"DROP TRIGGER IF EXISTS execution_transition_append_only ON execution_transaction_transition",
"
CREATE TRIGGER execution_transition_append_only
BEFORE UPDATE OR DELETE ON execution_transaction_transition
FOR EACH STATEMENT EXECUTE FUNCTION execution_transition_append_only()
",
"
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,View on GitHub (pinned to 18893faf8b)
Solutions
- Re-run the migration; the whole operation is transactional, so a transient database error rolls back cleanly.
- Grant the database role CREATE privileges on functions and triggers for the schema.
- Inspect the underlying {e} message to identify the exact failing statement (fence trigger, append-only trigger, or version upsert).
- Check that no partial migration left conflicting objects; drop stray execution_transaction_v2_fence / execution_transition_append_only triggers created outside the migration.
Defensive patterns
Strategy: try-catch
Validate before calling
-- preflight: privileges and no stray objects
SELECT has_schema_privilege(current_user, 'public', 'CREATE');
SELECT tgname FROM pg_trigger WHERE tgname IN ('execution_transaction_v2_fence','execution_transition_append_only'); Try / catch
if let Err(e) = migrate_execution_schema(&pool).await {
let msg = format!("{e:#}");
if msg.contains("Failed to activate execution schema version 2") {
// transactional: safely retry after fixing privileges/conflicts
}
} Prevention
- Grant the migration role CREATE ON SCHEMA privileges
- Run migrations on the primary, never a replica
- Check for leftover triggers from earlier partial migrations
When it happens
Trigger: Executing the v2 activation statement list during migration when the database rejects a statement: trigger/function creation failure, permission denied on CREATE TRIGGER/FUNCTION, existing conflicting objects, or the conditional upsert into execution_schema_version failing (e.g. version row conflict rule violated).
Common situations: Migrating a PostgreSQL user lacking CREATE privileges on the schema; a previous partial migration left conflicting triggers/functions; the execution_schema_version row was manually bumped above 2; database connectivity dropped mid-migration.
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 install verification schema: {e}
- Cannot safely migrate {unresolved_legacy} unresolved executi
- Failed to commit execution schema migration: {e}
- Execution payload rollback left {invalid} invalid row(s)
- Failed to persist signed transaction {transaction_hash}: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/507ca0d0ae93979f.
Report an issue: GitHub.