{"record":{"id":"4fc1e4d7a1ff0ebd","repo":"nautechsystems/nautilus_trader","slug":"failed-to-persist-connect-verification-e","errorCode":null,"errorMessage":"Failed to persist connect verification: {e}","messagePattern":"Failed to persist connect verification: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4557,"sourceCode":"                    NULL, NULL, 'connect', $1, $2, $3, $4, $5, $6, $7, $8,\n                    'all_valid', $9, $10, 'verified', $11\n                )\n                \",\n            )\n            .bind(decision.read_class)\n            .bind(height_start)\n            .bind(height_end)\n            .bind(bootstrap.manifest_version)\n            .bind(bootstrap.manifest_digest)\n            .bind(bootstrap.provider_ids)\n            .bind(bootstrap.operator_ids)\n            .bind(bootstrap.failure_domain_ids)\n            .bind(&decision.normalized_value_digest)\n            .bind(revision)\n            .bind(transition_key)\n            .execute(&mut *transaction)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to persist connect verification: {e}\"))?;\n        }\n\n        for statement in [\n            \"\n            CREATE OR REPLACE FUNCTION execution_verification_append_only()\n            RETURNS TRIGGER AS $$\n            BEGIN\n                RAISE EXCEPTION 'Execution verification evidence is append-only';\n            END;\n            $$ LANGUAGE plpgsql\n            \",\n            \"DROP TRIGGER IF EXISTS execution_verification_decision_append_only \\\n             ON execution_verification_decision\",\n            \"\n            CREATE TRIGGER execution_verification_decision_append_only\n            BEFORE UPDATE OR DELETE ON execution_verification_decision\n            FOR EACH STATEMENT EXECUTE FUNCTION execution_verification_append_only()\n            \",","sourceCodeStart":4539,"sourceCodeEnd":4575,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L4539-L4575","documentation":"Thrown while persisting a connect-verification decision row into the `execution_verification_decision` table inside the execution verification schema migration transaction. The library wraps the underlying sqlx/Postgres error so callers get context about which migration step failed. The insert itself is idempotent-looking append-only evidence written once per (revision, decision index).","triggerScenarios":"`ensure_execution_verification_schema` runs during database bootstrap and any of the per-decision INSERTs fails: schema/table missing, column type mismatch (e.g. height exceeding BIGINT already rejected earlier, but digest/manifest type mismatch possible), constraint violation on transition_key (duplicate revision), or connection dropped mid-transaction.","commonSituations":"Upgrading an older database where the table schema predates a new column; a concurrent migration running on the same database causing unique violations on transition_key; network interruption between app and Postgres during startup; running against a non-Postgres or partially migrated database.","solutions":["Read the inner sqlx error in the message to identify the exact DB failure","Run the schema migrations / check `execution_schema_version` to confirm the verification schema exists at the expected version","Check for concurrent instances running the migration against the same database and ensure only one bootstrap at a time","Verify Postgres connectivity and that the user has INSERT privileges on execution_verification_decision"],"exampleFix":"// before: connecting to a stale/partially migrated DB and hitting the error\nDatabase::connect(pool).await?;\n// after: verify schema version before bootstrapping\nlet version: Option<i16> = sqlx::query_scalar(\n    \"SELECT version FROM execution_schema_version WHERE component = 'evm_execution_verification'\")\n    .fetch_optional(&pool).await?;\nassert!(version.is_none() || version == Some(VERIFICATION_SCHEMA_VERSION));","handlingStrategy":"try-catch","validationCode":"let ok: bool = sqlx::query_scalar(\n    \"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'execution_verification_decision')\")\n    .fetch_one(&pool).await?;\nif !ok { run_table_migration_first()?; }","typeGuard":null,"tryCatchPattern":"match ensure_verification_schema(&db).await {\n    Err(e) if e.to_string().contains(\"Failed to persist connect verification\") => {\n        log::error!(\"verification write failed: {e:#}\"); // inspect root-cause chain, check schema/privileges, retry bootstrap\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Run schema migrations before application bootstrap and gate startup on them","Grant the app role INSERT on all execution_* tables","Ensure only one instance performs migration on a database at once (advisory lock)","Monitor Postgres connectivity during startup"],"tags":["postgres","sqlx","schema-migration"],"backgroundTag":"database-write-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}