{"record":{"id":"0b078a5c16d42d7a","repo":"nautechsystems/nautilus_trader","slug":"failed-to-update-execution-intent-intent-id-e","errorCode":null,"errorMessage":"Failed to update execution intent {intent_id}: {e}","messagePattern":"Failed to update execution intent (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":6847,"sourceCode":"        .map_err(|e| anyhow::anyhow!(\"Failed to update execution hash {transaction_hash}: {e}\"))?;\n        anyhow::ensure!(\n            hash_result.rows_affected() == 1,\n            \"Execution transaction hash {transaction_hash} was not found for intent {intent_id}\"\n        );\n\n        sqlx::query(\n            \"\n            UPDATE execution_intent\n            SET status = $2, active = $3, updated_at = NOW()\n            WHERE id = $1\n            \",\n        )\n        .bind(intent_id)\n        .bind(status.as_str())\n        .bind(active)\n        .execute(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to update execution intent {intent_id}: {e}\"))?;\n\n        let transition_key = format!(\n            \"{}:{transaction_hash}:{}:{}\",\n            status.as_str(),\n            block_number.map_or_else(|| \"none\".to_string(), |value| value.to_string()),\n            block_hash.unwrap_or(\"none\")\n        );\n        sqlx::query(\n            \"\n            INSERT INTO execution_transaction_transition (\n                intent_id, transaction_hash_id, transition_key, from_status, to_status,\n                block_number, block_hash\n            )\n            SELECT $1, id, $3, $4, $5, $6, $7\n            FROM execution_transaction_hash\n            WHERE intent_id = $1 AND transaction_hash = $2\n            ON CONFLICT (intent_id, transition_key) DO NOTHING\n            \",","sourceCodeStart":6829,"sourceCodeEnd":6865,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L6829-L6865","documentation":"Raised when the UPDATE of the execution_intent row itself (setting the new status and active flag) fails inside the transition transaction. Locking, validation, and the execution-hash update already succeeded, but this final status write errored, rolling back the entire transaction.","triggerScenarios":"Calling the transition when the intent UPDATE statement errors: connection dropped mid-transaction, schema/constraint mismatch on status or active columns, deferred constraint violation from earlier statements, or statement timeout.","commonSituations":"Long-running transactions killed by idle_in_transaction_session_timeout while waiting on row locks under concurrency; migration drift changing the status column type/enum; database failover dropping the session mid-transaction.","solutions":["Read the inner `{e}` for the precise SQL error and fix the underlying cause (schema, constraint, connection).","Retry the whole transition with backoff — the transaction rolled back cleanly, so state is consistent.","Reduce lock hold time (shorten the transaction) to avoid connection drops under contention.","Run pending migrations if the status column definition changed in a newer adapter version."],"exampleFix":"// before\n.map_err(|e| anyhow::anyhow!(\"Failed to update execution intent {intent_id}: {e}\"))?;\n// after\n.map_err(|e| anyhow::anyhow!(\"Failed to update execution intent {intent_id} to {}: {e}\", status.as_str()))?;","handlingStrategy":"retry","validationCode":"// Pre-flight: ensure status column accepts the value\nsqlx::query(\"SELECT status FROM execution_intent LIMIT 1\").execute(&pool).await?;","typeGuard":null,"tryCatchPattern":"match transition.await {\n    Err(e) if e.to_string().contains(\"Failed to update execution intent\") => {\n        tracing::error!(error = %e, \"intent update failed; transaction rolled back, safe to retry\");\n        retry_with_backoff();\n    }\n    other => other?,\n}","preventionTips":["Keep the transition transaction short to avoid session timeouts under lock contention.","Apply schema migrations before the new adapter version writes new statuses.","Monitor for connection drops during failover and alert on commit/update failures."],"tags":["database","sqlx","update","transaction"],"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-23T08:17:48.524Z"}