nautechsystems/nautilus_trader · error · anyhow::Error
Failed to update execution hash
Error message
Failed to update execution hash {transaction_hash}: {e} What it means
Raised when the UPDATE that stores execution transaction details (block hash, receipt success, gas used, effective gas price) keyed by transaction_hash fails at the database level inside the transition transaction. The row-lock and status validation already succeeded, but persisting the receipt details errored, so the whole transaction rolls back.
Solutions
- Read the inner `{e}` for the exact SQL error; fix the schema/migration if it is a column or constraint issue.
- Verify gas values and hash formats match the column types before binding (Decimal for gas, bytea/text for hashes).
- Retry transient connection errors; ensure the transaction was not already aborted by a previous failed statement.
- Confirm the UPDATE's WHERE clause matches the row layout — a persistent 0-rows case surfaces as error 2315 instead.
Example fix
// before
.execute(&mut *transaction)
.await
.map_err(|e| anyhow::anyhow!("Failed to update execution hash {transaction_hash}: {e}"))?;
// after
.execute(&mut *transaction)
.await
.with_context(|| format!("Failed to update execution hash {transaction_hash} for intent {intent_id}"))?; Defensive patterns
Strategy: retry
Validate before calling
// Pre-check schema compatibility before receipt processing
sqlx::query("SELECT block_hash, receipt_success, gas_used, effective_gas_price FROM execution_transaction LIMIT 1")
.execute(&pool).await?; Try / catch
match transition.await {
Err(e) if e.to_string().contains("Failed to update execution hash") => {
tracing::error!(error = %e, "receipt write failed; rolling back and retrying");
retry_with_backoff();
}
other => other?,
} Prevention
- Run migrations on every deploy before event processing starts.
- Bind gas values as Decimal and hashes in the column's exact type/format.
- Never reuse a transaction after an earlier statement error (it is aborted).
When it happens
Trigger: Calling the transition method when the execution-hash UPDATE statement errors: schema mismatch (column type/constraint change after migration), connection lost mid-transaction, numeric overflow binding gas values, or a CHECK constraint rejection on receipt data.
Common situations: Schema drift after upgrading the adapter without running migrations; Postgres numeric/bytea type mismatch for hashes; transaction aborted earlier in the session by a prior error ('current transaction is aborted'); connection pool idle timeout killing the socket mid-statement.
Related errors
- Failed to update execution intent
- Failed to advance canonical nonce ledger
- Failed to commit execution transition
- Failed to commit verified action evidence
- Failed to commit verified finality transition
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/c978689eb4b344b3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/blockchain/src/cache/database.rs:6829
block_hash = COALESCE($5, block_hash),
receipt_success = COALESCE($6, receipt_success),
gas_used = COALESCE($7, gas_used),
effective_gas_price = COALESCE($8, effective_gas_price),
updated_at = NOW()
WHERE intent_id = $1 AND transaction_hash = $2
",
)
.bind(intent_id)
.bind(transaction_hash)
.bind(status.as_str())
.bind(block_number_db)
.bind(block_hash)
.bind(receipt_success)
.bind(gas_used_db)
.bind(effective_gas_price)
.execute(&mut *transaction)
.await
.map_err(|e| anyhow::anyhow!("Failed to update execution hash {transaction_hash}: {e}"))?;
anyhow::ensure!(
hash_result.rows_affected() == 1,
"Execution transaction hash {transaction_hash} was not found for intent {intent_id}"
);
sqlx::query(
"
UPDATE execution_intent
SET status = $2, active = $3, updated_at = NOW()
WHERE id = $1
",
)
.bind(intent_id)
.bind(status.as_str())
.bind(active)
.execute(&mut *transaction)
.await
.map_err(|e| anyhow::anyhow!("Failed to update execution intent {intent_id}: {e}"))?;View on GitHub (pinned to 18893faf8b)