{"record":{"id":"04a432702455c803","repo":"nautechsystems/nautilus_trader","slug":"failed-to-commit-verified-nonce-assignment-e","errorCode":null,"errorMessage":"Failed to commit verified nonce assignment: {e}","messagePattern":"Failed to commit verified nonce assignment: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":6039,"sourceCode":"              AND active\n              AND (nonce IS NULL OR nonce = $2)\n            \",\n        )\n        .bind(assignment.intent_id)\n        .bind(nonce)\n        .execute(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to assign verified execution nonce: {e}\"))?;\n        anyhow::ensure!(\n            result.rows_affected() == 1,\n            \"Execution intent {} is not prepared for canonical nonce {}\",\n            assignment.intent_id,\n            assignment.nonce\n        );\n        transaction\n            .commit()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to commit verified nonce assignment: {e}\"))?;\n        Ok(())\n    }\n\n    /// Appends one verified decision batch before an action on an existing active intent.\n    pub(crate) async fn record_execution_verification_batch(\n        &self,\n        batch: &ExecutionVerificationBatch<'_>,\n    ) -> anyhow::Result<()> {\n        anyhow::ensure!(\n            !batch.decision_class.trim().is_empty() && !batch.decisions.is_empty(),\n            \"Verified action requires a decision class and evidence\"\n        );\n        anyhow::ensure!(\n            batch.provider_ids.len() == 3\n                && batch.operator_ids.len() == 3\n                && batch.failure_domain_ids.len() >= 3,\n            \"Verified action requires the configured provider identities\"\n        );","sourceCodeStart":6021,"sourceCodeEnd":6057,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L6021-L6057","documentation":"Thrown when the PostgreSQL transaction that assigns a verified execution nonce fails to commit after all statements succeeded. The database rejects or cannot finalize the transaction (connection loss, serialization failure, constraint violation surfaced at commit), so the entire nonce assignment is rolled back and reported via anyhow.","triggerScenarios":"transaction.commit() returns Err during the verified nonce assignment flow — typically a dropped connection, network partition to Postgres, deadlock, or serialization failure between the UPDATE and commit.","commonSituations":"Idle-in-transaction timeouts killing the connection; network blips between the app and the database; Postgres failover mid-transaction; long-running verification work holding the transaction open too long.","solutions":["Retry the whole nonce-assignment operation; it is transactional, so a failed commit leaves no partial state.","Check database connectivity and logs for connection drops, deadlocks, or serialization failures around the failure time.","Shorten the work done between pool.begin() and commit(), or move non-DB work outside the transaction.","Tune connection pool/statement timeouts (sqlx pool options, statement_timeout) if idle-in-transaction limits are the cause."],"exampleFix":"// before: single attempt\nassign_verified_execution_nonce(&pool, &assignment).await?;\n// after: retry transient commit failures\nfor attempt in 0..3 {\n    match assign_verified_execution_nonce(&pool, &assignment).await {\n        Ok(()) => break,\n        Err(e) if attempt < 2 && is_transient_db_error(&e) => tokio::time::sleep(backoff(attempt)).await,\n        Err(e) => return Err(e),\n    }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust\nmatch assign_nonce().await {\n    Err(e) if e.to_string().contains(\"Failed to commit verified nonce assignment\") && is_transient(&e) => retry_with_backoff(),\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Keep transactions short; avoid network calls between begin and commit.","Set sane statement_timeout and pool acquire timeouts.","Monitor Postgres for deadlocks and connection drops."],"tags":["database","transaction","commit","rust"],"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-14T00:17:10.932Z"}