{"record":{"id":"507ca0d0ae93979f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-activate-execution-schema-version-2-e","errorCode":null,"errorMessage":"Failed to activate execution schema version 2: {e}","messagePattern":"Failed to activate execution schema version 2: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":3661,"sourceCode":"            \",\n            \"DROP TRIGGER IF EXISTS execution_transition_append_only ON execution_transaction_transition\",\n            \"\n            CREATE TRIGGER execution_transition_append_only\n            BEFORE UPDATE OR DELETE ON execution_transaction_transition\n            FOR EACH STATEMENT EXECUTE FUNCTION execution_transition_append_only()\n            \",\n            \"\n            INSERT INTO execution_schema_version (component, version)\n            VALUES ('evm_execution', 2)\n            ON CONFLICT (component) DO UPDATE SET version = EXCLUDED.version\n            WHERE execution_schema_version.version <= EXCLUDED.version\n            \",\n        ] {\n            sqlx::query(statement)\n                .execute(&mut *transaction)\n                .await\n                .map_err(|e| {\n                    anyhow::anyhow!(\"Failed to activate execution schema version 2: {e}\")\n                })?;\n        }\n\n        transaction\n            .commit()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to commit execution schema migration: {e}\"))?;\n\n        Ok(())\n    }\n\n    /// Loads the durable finalized-header and nonce position when verification is active.\n    pub(crate) async fn load_execution_verification_position(\n        &self,\n        chain_id: u32,\n        wallet_address: &str,\n        manifest_version: &str,\n        manifest_digest: &str,","sourceCodeStart":3643,"sourceCodeEnd":3679,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L3643-L3679","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"-- preflight: privileges and no stray objects\nSELECT has_schema_privilege(current_user, 'public', 'CREATE');\nSELECT tgname FROM pg_trigger WHERE tgname IN ('execution_transaction_v2_fence','execution_transition_append_only');","typeGuard":null,"tryCatchPattern":"if let Err(e) = migrate_execution_schema(&pool).await {\n    let msg = format!(\"{e:#}\");\n    if msg.contains(\"Failed to activate execution schema version 2\") {\n        // transactional: safely retry after fixing privileges/conflicts\n    }\n}","preventionTips":["Grant the migration role CREATE ON SCHEMA privileges","Run migrations on the primary, never a replica","Check for leftover triggers from earlier partial migrations"],"tags":["database","migration","sql","postgresql"],"backgroundTag":"sql-query-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}