{"record":{"id":"7704165812654471","repo":"nautechsystems/nautilus_trader","slug":"failed-to-commit-execution-transition-e","errorCode":null,"errorMessage":"Failed to commit execution transition: {e}","messagePattern":"Failed to commit execution transition: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":6881,"sourceCode":"            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<()> {\n        anyhow::ensure!(\n            matches!(\n                finality.status,\n                TransactionStatus::Finalized | TransactionStatus::Reverted\n            ),","sourceCodeStart":6863,"sourceCodeEnd":6899,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L6863-L6899","documentation":"Raised when transaction.commit() fails after all statements in the execution-status transition succeeded. Nothing is persisted (the transaction rolls back implicitly), even though row locks, validation, and writes all passed locally. This typically indicates the connection to the database was lost between the last statement and the commit.","triggerScenarios":"Calling the transition when COMMIT fails: network drop or database restart mid-transaction, idle_in_transaction_session_timeout terminating the session after long lock waits, admin-initiated pg_terminate_backend, or serialization/deadlock detection aborting the commit.","commonSituations":"Long lock contention on the intent row (another worker holding FOR UPDATE) pushing past the session timeout; database failover during receipt processing; firewall/NAT dropping idle connections between statements.","solutions":["Retry the entire transition with backoff — the rollback left state consistent, so a retry is safe.","Shorten the transaction (do non-critical work outside it) to stay under idle-in-transaction timeouts.","Tune Postgres idle_in_transaction_session_timeout and the pool's acquire/idle timeouts for the workload.","Check server logs for 'terminating connection' or deadlock messages at the failure timestamp."],"exampleFix":"// before\ntransaction.commit().await.map_err(|e| anyhow::anyhow!(\"Failed to commit execution transition: {e}\"))?;\n// after\nif let Err(e) = transaction.commit().await {\n    tracing::warn!(error = %e, \"commit failed; state unchanged, safe to retry\");\n    return Err(anyhow::anyhow!(\"Failed to commit execution transition: {e}\"));\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"loop {\n    match transition.await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"Failed to commit execution transition\") && attempts < MAX_RETRIES => {\n            attempts += 1;\n            tokio::time::sleep(backoff.next()).await; // rollback left state consistent\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Tune idle_in_transaction_session_timeout above worst-case lock wait times.","Do heavy work (receipt parsing, hashing) before BEGIN, not inside the transaction.","Enable TCP keepalives on the database connection to survive NAT/firewall idle drops.","Retries are safe: a failed COMMIT rolls everything back atomically."],"tags":["database","transaction","commit","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"}