{"record":{"id":"2c03433f5844605f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-read-execution-schema-version-e","errorCode":null,"errorMessage":"Failed to read execution schema version: {e}","messagePattern":"Failed to read execution schema version: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":3596,"sourceCode":"                )),\n                UNIQUE (intent_id, transition_key)\n            )\n            \",\n        ] {\n            sqlx::query(statement)\n                .execute(&mut *transaction)\n                .await\n                .map_err(|e| {\n                    anyhow::anyhow!(\"Failed to migrate execution_transaction table: {e}\")\n                })?;\n        }\n\n        let installed_version = sqlx::query_scalar::<_, i16>(\n            \"SELECT version FROM execution_schema_version WHERE component = 'evm_execution'\",\n        )\n        .fetch_optional(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to read execution schema version: {e}\"))?;\n        if let Some(installed_version) = installed_version\n            && installed_version > EXECUTION_SCHEMA_VERSION\n        {\n            anyhow::bail!(\n                \"Execution schema version {} is newer than supported version {EXECUTION_SCHEMA_VERSION}\",\n                installed_version\n            );\n        }\n\n        let unresolved_legacy = sqlx::query_scalar::<_, i64>(\n            \"\n            SELECT COUNT(*)\n            FROM execution_transaction\n            WHERE status IN ('pending', 'included', 'reverted')\n            \",\n        )\n        .fetch_one(&mut *transaction)\n        .await","sourceCodeStart":3578,"sourceCodeEnd":3614,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L3578-L3614","documentation":"This error wraps failure reading the installed schema version from execution_schema_version (`SELECT version ... WHERE component = 'evm_execution'`). The library throws it to distinguish version-lookup failures from DDL failures during migration.","triggerScenarios":"ensure_execution_transaction_schema runs and the execution_schema_version table is missing, the version column has an unexpected type (query_scalar expects i16), or the query fails due to connectivity/permissions.","commonSituations":"Partially applied earlier migration that created execution_transaction but not execution_schema_version; manual schema edits; smallint vs integer type mismatch in the version column.","solutions":["Ensure execution_schema_version table exists with a smallint version column (create it in the same migration)","Verify connectivity and SELECT privileges on execution_schema_version","Compare the column type to i16 (SMALLINT); alter if it was created as INTEGER","Re-run migrations in order so version tracking is initialized before it is read"],"exampleFix":"// before\n.map_err(|e| anyhow::anyhow!(\"Failed to read execution schema version: {e}\"))?;\n// after\n.map_err(|e| {\n    tracing::error!(error = %e, \"execution_schema_version read failed\");\n    anyhow::anyhow!(\"Failed to read execution schema version: {e}\")\n})?;","handlingStrategy":"try-catch","validationCode":"let has_version_table = sqlx::query_scalar::<_, bool>(\n    \"SELECT to_regclass('execution_schema_version') IS NOT NULL\"\n).fetch_one(&pool).await?;\nif !has_version_table { anyhow::bail!(\"execution_schema_version missing; initialize version tracking first\"); }","typeGuard":null,"tryCatchPattern":"match db.ensure_execution_transaction_schema().await {\n    Ok(()) => (),\n    Err(e) if e.to_string().contains(\"Failed to read execution schema version\") => {\n        init_execution_schema_version_table(&pool).await?;\n        db.ensure_execution_transaction_schema().await?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Create execution_schema_version in the same migration that creates the table","Use SMALLINT for the version column to match query_scalar::<_, i16>","Never manually edit or drop version tracking tables"],"tags":["database","migration","versioning"],"backgroundTag":"record-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}