{"record":{"id":"53f0a6a3c58266a3","repo":"nautechsystems/nautilus_trader","slug":"failed-to-number-verified-action-evidence-e","errorCode":null,"errorMessage":"Failed to number verified action evidence: {e}","messagePattern":"Failed to number verified action evidence: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":6116,"sourceCode":"        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to lock intent for verified action: {e}\"))?\n        .ok_or_else(|| anyhow::anyhow!(\"Active verified-action intent was not found\"))?;\n        anyhow::ensure!(\n            intent_nonce == Some(nonce),\n            \"Verified action nonce does not match the active intent\"\n        );\n        let attempt = sqlx::query_scalar::<_, i64>(\n            \"\n            SELECT COUNT(*)\n            FROM execution_verification_decision\n            WHERE intent_id = $1 AND decision_class = $2\n            \",\n        )\n        .bind(batch.intent_id)\n        .bind(batch.decision_class)\n        .fetch_one(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to number verified action evidence: {e}\"))?;\n\n        for (index, decision) in batch.decisions.iter().enumerate() {\n            let height_start = decision\n                .height_start\n                .map(i64::try_from)\n                .transpose()\n                .context(\"Verification height exceeds PostgreSQL BIGINT\")?;\n            let height_end = decision\n                .height_end\n                .map(i64::try_from)\n                .transpose()\n                .context(\"Verification height exceeds PostgreSQL BIGINT\")?;\n            let transition_key = format!(\n                \"{}:{}:{attempt}:{}:{index}\",\n                batch.decision_class, batch.intent_id, decision.read_class\n            );\n            sqlx::query(\n                \"","sourceCodeStart":6098,"sourceCodeEnd":6134,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L6098-L6134","documentation":"Inside record_execution_verification_batch, the code counts existing evidence rows for the intent/decision_class to number the batch (the `attempt` used in transition_key). If the COUNT(*) query fails at the database level, it is wrapped as this error.","triggerScenarios":"The SELECT COUNT(*) FROM execution_verification_decision WHERE intent_id = $1 AND decision_class = $2 query fails: connection drop, transaction already aborted by a prior error, statement timeout, or the table missing (schema not migrated).","commonSituations":"Postgres connection pool exhaustion or network blip mid-transaction; running against a database missing recent migrations; a previous statement in the transaction aborted it so subsequent queries fail.","solutions":["Check database connectivity and retry the whole batch operation; the transaction is atomic so a retry is safe","Run pending migrations so execution_verification_decision exists","Look at the inner `{e}` source for the underlying sqlx/Postgres error code","Ensure no earlier statement in the transaction has aborted it before this query"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify schema exists before calling\nsqlx::query(\"SELECT 1 FROM execution_verification_decision LIMIT 1\")\n    .fetch_optional(&pool).await?\n    .ok_or_else(|| anyhow::anyhow!(\"migrations missing\"))?;","typeGuard":null,"tryCatchPattern":"if let Err(e) = db.record_execution_verification_batch(&batch).await {\n    if e.to_string().contains(\"Failed to number verified action evidence\") {\n        // transient DB issue: backoff and retry whole batch (transaction is atomic)\n        tokio::time::sleep(Duration::from_secs(1)).await;\n        return retry(batch).await;\n    }\n    return Err(e);\n}","preventionTips":["Keep migrations current with the binary version","Monitor pool health and connection errors","Keep the whole batch in one transaction (already done) so retries are safe","Log the inner source chain ({e:?}) to distinguish transient vs schema errors"],"tags":["database","sqlx","postgres","query"],"backgroundTag":"database-query-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"}