{"record":{"id":"8e05436417856db6","repo":"nautechsystems/nautilus_trader","slug":"failed-to-commit-execution-intent-reservation","errorCode":null,"errorMessage":"failed to commit execution intent reservation","messagePattern":"failed to commit execution intent reservation","errorType":"exception","errorClass":"ExecutionIntentReservationError","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":5837,"sourceCode":"                \",\n            )\n            .bind(row.id)\n            .bind(created_block)\n            .execute(&mut *transaction)\n            .await\n            .context(\"failed to record prepared execution intent\")?;\n\n            Ok::<_, anyhow::Error>((transaction, row))\n        }\n        .await\n        .map_err(|source| {\n            anyhow::Error::new(ExecutionIntentReservationError {\n                stage: ExecutionIntentReservationStage::BeforeCommit,\n                source,\n            })\n        })?;\n        transaction.commit().await.map_err(|e| {\n            anyhow::Error::new(ExecutionIntentReservationError {\n                stage: ExecutionIntentReservationStage::Commit,\n                source: anyhow::Error::new(e)\n                    .context(\"failed to commit execution intent reservation\"),\n            })\n        })?;\n        Ok(row)\n    }\n\n    /// Assigns the signer nonce to a prepared execution intent.\n    ///\n    /// Repeating the same assignment is idempotent. A different nonce or non-prepared state\n    /// fails closed.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the intent cannot own the nonce or persistence fails.\n    pub async fn assign_execution_intent_nonce(\n        &self,","sourceCodeStart":5819,"sourceCodeEnd":5855,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L5819-L5855","documentation":"This error is raised when transaction.commit() fails while finalizing an execution intent reservation in the blockchain cache database. The adapter wraps the commit error in ExecutionIntentReservationError with stage Commit and the context message \"failed to commit execution intent reservation\", signaling that the reservation may or may not have been durably persisted (commit outcome is unknown), so callers must treat the reservation state as indeterminate.","triggerScenarios":"Calling the execution-intent reservation routine and the sqlx transaction commit fails — typically connection drop between the prepared writes and COMMIT, serialization failure, or DB server shutdown.","commonSituations":"Network blip between app and Postgres at commit time; database failover or restart during the transaction; lock contention causing the commit to be aborted; idle-in-transaction timeout killing the session.","solutions":["Check the wrapped source for the sqlx commit error to determine if the commit actually landed (query the row by intent key)","Treat reservation state as unknown: reconcile by reading the intents table before retrying","Retry the reservation; if the row already exists, handle the duplicate-key path gracefully","Harden DB connectivity (timeouts, retries, pool limits) to reduce mid-transaction disconnects","Enable statement/slow-query logging on the database to catch commit-time aborts"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the row's persisted state after a commit failure before retrying\nlet existing = sqlx::query(\"SELECT 1 FROM execution_intents WHERE key = $1\")\n    .bind(&intent.key)\n    .fetch_optional(&pool)\n    .await?;","typeGuard":"fn is_commit_stage(err: &ExecutionIntentReservationError) -> bool {\n    matches!(err.stage, ExecutionIntentReservationStage::Commit)\n}","tryCatchPattern":"match reserve_intent(&pool, intent).await {\n    Err(e) if is_commit_stage(&e) => {\n        // commit outcome unknown: reconcile by reading the row before retry\n        reconcile_or_retry(&pool, intent).await\n    }\n    other => other,\n}","preventionTips":["Treat commit-stage failures as indeterminate — always reconcile before retrying","Keep transactions short to reduce commit-time abort windows","Configure TCP keepalive and sensible timeouts on the DB connection","Watch DB logs for failovers, deadlocks, and session kills"],"tags":["database","transaction-commit","blockchain","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-14T05:17:10.506Z"}