{"record":{"id":"50d3c5a7aaac92d0","repo":"nautechsystems/nautilus_trader","slug":"failed-to-record-execution-transition-e","errorCode":null,"errorMessage":"Failed to record execution transition: {e}","messagePattern":"Failed to record execution transition: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":6876,"sourceCode":"                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            \",\n        )\n        .bind(intent_id)\n        .bind(transaction_hash)\n        .bind(transition_key)\n        .bind(current_status)\n        .bind(status.as_str())\n        .bind(block_number_db)\n        .bind(block_hash)\n        .execute(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to record execution transition: {e}\"))?;\n\n        transaction\n            .commit()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to commit execution transition: {e}\"))?;\n        Ok(())\n    }\n\n    /// Records verified final consumption and advances the canonical nonce in one transaction.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the receipt transition, nonce ledger, manifest identity, or evidence\n    /// is inconsistent, or if persistence fails.\n    pub(crate) async fn record_execution_finality_verified(\n        &self,\n        finality: &ExecutionFinalityTransition<'_>,\n    ) -> anyhow::Result<()> {","sourceCodeStart":6858,"sourceCodeEnd":6894,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L6858-L6894","documentation":"Raised when the INSERT into the execution transition audit/history table (recording from_status -> to_status with block number/hash) fails inside the transaction. All state updates succeeded, but persisting the audit trail errored, so the whole transition rolls back to keep state and history consistent.","triggerScenarios":"Calling the transition when the history INSERT errors: missing transition-history table (migration not run), NOT NULL violation (e.g. block_number_db bound as NULL into a non-null column), connection failure, or sequence/serial exhaustion.","commonSituations":"Deploying a version that writes history before applying its migration; NULL block_number for mempool/pending transitions hitting a NOT NULL column; database disk full or connection drop during heavy event bursts.","solutions":["Read the inner `{e}`; if it names a missing relation, apply pending migrations for the transition-history table.","Check NULL handling: ensure block_number_db/block_hash are nullable or defaulted in the schema for pre-finality transitions.","Retry the full transition with backoff on transient connection errors.","Check database disk space and write capacity during receipt-processing bursts."],"exampleFix":"// before\n.bind(block_number_db)\n.bind(block_hash)\n.execute(&mut *transaction)\n.await\n.map_err(|e| anyhow::anyhow!(\"Failed to record execution transition: {e}\"))?;\n// after\n.bind(block_number_db) // ensure column allows NULL for pending transitions\n.bind(block_hash)\n.execute(&mut *transaction)\n.await\n.with_context(|| format!(\"Failed to record execution transition {current_status} -> {} for intent\", status.as_str()))?;","handlingStrategy":"try-catch","validationCode":"// Verify the history table exists and allows NULL block numbers\nsqlx::query(\"SELECT 1 FROM execution_transition_history LIMIT 1\").execute(&pool).await?;\n// and check column nullability in information_schema for block_number","typeGuard":null,"tryCatchPattern":"if let Err(e) = transition.await {\n    let msg = e.to_string();\n    if msg.contains(\"Failed to record execution transition\") {\n        if msg.contains(\"does not exist\") { run_migrations()?; }\n        else if msg.contains(\"null value\") { fix_null_block_number_path()?; }\n        else { retry_with_backoff(); }\n    }\n}","preventionTips":["Apply migrations for the transition-history table on every deploy.","Make block_number/block_hash nullable in the history schema for pre-finality transitions.","Monitor disk space; INSERT-heavy audit trails fail on full disks."],"tags":["database","audit","insert","sqlx"],"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"}