{"record":{"id":"3f36cd32169496de","repo":"nautechsystems/nautilus_trader","slug":"failed-to-validate-nonce-recovery-ownership-e","errorCode":null,"errorMessage":"Failed to validate nonce recovery ownership: {e}","messagePattern":"Failed to validate nonce recovery ownership: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4072,"sourceCode":"                                   + (hash.sealed_transaction IS NOT NULL)::INTEGER) = 1\n                              AND hash.status IN (\n                                  'broadcast', 'included', 'replaced', 'dropped', 'reorged'\n                              )\n                        )\n                    FROM execution_intent AS intent\n                    LEFT JOIN execution_transaction_hash AS hash\n                        ON hash.intent_id = intent.id\n                    WHERE intent.chain_id = $1\n                      AND intent.wallet_address = $2\n                      AND intent.active\n                    GROUP BY intent.id, intent.nonce, intent.status\n                    \",\n                )\n                .bind(chain_id)\n                .bind(bootstrap.wallet_address)\n                .fetch_optional(&mut *transaction)\n                .await\n                .map_err(|e| anyhow::anyhow!(\"Failed to validate nonce recovery ownership: {e}\"))?;\n                let Some((intent_nonce, intent_status, payload_count)) = recovery else {\n                    anyhow::bail!(\n                        \"Verified finalized transaction count advanced without an active owned intent\"\n                    );\n                };\n                anyhow::ensure!(\n                    intent_nonce == Some(stored_nonce)\n                        && matches!(\n                            intent_status.as_str(),\n                            \"broadcast\" | \"included\" | \"replaced\" | \"dropped\" | \"reorged\"\n                        )\n                        && payload_count == 1,\n                    \"Verified finalized transaction count advanced without one recoverable retained payload at the durable nonce\"\n                );\n            }\n            revision\n        } else {\n            anyhow::ensure!(","sourceCodeStart":4054,"sourceCodeEnd":4090,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L4054-L4090","documentation":"The ownership-validation query that checks for an active execution intent owning the recovered nonce failed at the database level; crates/adapters/blockchain/src/cache/database.rs:4072 wraps the sqlx error with this message. This is an infrastructure/database failure (connectivity, permissions, lock contention, schema mismatch) rather than a business-rule violation — the query itself could not complete.","triggerScenarios":"The SELECT over execution_intent joined with execution_transaction_hash returns a database error during the nonce recovery branch of verification bootstrap: connection drop, statement timeout under the ACCESS EXCLUSIVE table lock, missing tables/columns (schema version mismatch), or insufficient privileges.","commonSituations":"Transient Postgres restart or failover mid-bootstrap; another migration dropped or renamed execution_intent columns; lock queue behind a long-running transaction holding the verification tables; connection pool exhausted; user lacking SELECT on the tables.","solutions":["Inspect the wrapped sqlx error in the {e} message to identify the root cause (connection, timeout, permission, or schema).","Test connectivity and retry after transient failures (connection reset, server restart).","Verify the schema matches the expected verification schema version (execution_schema_version for 'evm_execution_verification') and run pending migrations.","Check for lock contention on execution_intent/execution_transaction_hash and long-running transactions blocking the ACCESS EXCLUSIVE lock.","Confirm the database role has SELECT on execution_intent and execution_transaction_hash."],"exampleFix":"// before\n// bootstrap retried immediately on any db failure, masking the root sqlx error\nrun_bootstrap().await?;\n\n// after\nmatch run_bootstrap().await {\n    Err(e) if e.to_string().contains(\"Failed to validate nonce recovery ownership\") => {\n        // log the inner sqlx error, check connectivity/schema, retry with backoff\n        tracing::error!(error = ?e, \"nonce recovery ownership check failed\");\n        retry_with_backoff(run_bootstrap).await?\n    }\n    other => other?,\n}","handlingStrategy":"retry","validationCode":"// pre-check the tables are queryable before entering bootstrap\nsqlx::query(\"SELECT 1 FROM execution_intent LIMIT 1\").execute(&pool).await?;\nsqlx::query(\"SELECT 1 FROM execution_transaction_hash LIMIT 1\").execute(&pool).await?;","typeGuard":null,"tryCatchPattern":"match bootstrap_verification(...).await {\n    Err(e) if e.to_string().contains(\"Failed to validate nonce recovery ownership\") => {\n        // inspect inner sqlx error; retry with backoff for transient errors, fail fast on schema/permission errors\n        if is_transient(&e) { retry_with_backoff(|| bootstrap_verification(...), 3).await? } else { return Err(e) }\n    }\n    other => other?,\n}","preventionTips":["Run schema version checks and migrations before bootstrap","Use connection-pool health checks and sensible statement timeouts","Grant the database role SELECT on execution_intent and execution_transaction_hash","Monitor and minimize long-running transactions that block the verification table locks"],"tags":["database","postgresql","sqlx","network"],"backgroundTag":"database-query-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"}