{"record":{"id":"70822522b3c9caf0","repo":"nautechsystems/nautilus_trader","slug":"failed-to-start-execution-status-transition-e","errorCode":null,"errorMessage":"Failed to start execution status transition: {e}","messagePattern":"Failed to start execution status transition: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":3615,"sourceCode":"            .map(i64::try_from)\n            .transpose()\n            .with_context(|| {\n                format!(\n                    \"Execution block number {} exceeds PostgreSQL BIGINT\",\n                    block_number.unwrap_or_default()\n                )\n            })?;\n        let gas_used_db = gas_used.map(i64::try_from).transpose().with_context(|| {\n            format!(\n                \"Execution gas used {} exceeds PostgreSQL BIGINT\",\n                gas_used.unwrap_or_default()\n            )\n        })?;\n        let mut transaction = self\n            .pool\n            .begin()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to start execution status transition: {e}\"))?;\n        let (current_status, fill_emitted, terminal_emitted) =\n            sqlx::query_as::<_, (String, bool, bool)>(\n            \"SELECT status, fill_emitted, terminal_emitted FROM execution_intent WHERE id = $1 FOR UPDATE\",\n        )\n        .bind(intent_id)\n        .fetch_optional(&mut *transaction)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Failed to lock execution intent {intent_id}: {e}\"))?\n        .ok_or_else(|| anyhow::anyhow!(\"Execution intent {intent_id} was not found\"))?;\n        anyhow::ensure!(\n            execution_transition_allowed(&current_status, status),\n            \"Invalid execution transition for intent {intent_id}: {current_status} -> {}\",\n            status.as_str()\n        );\n\n        let active = match status {\n            TransactionStatus::Finalized | TransactionStatus::Reverted => {\n                !fill_emitted && !terminal_emitted","sourceCodeStart":3597,"sourceCodeEnd":3633,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/2114cf6f761429e0adb5ca9596fcd7b895b16011/crates/adapters/blockchain/src/cache/database.rs#L3597-L3633","documentation":"Thrown when record_execution_status fails at pool.begin(), before the receipt observation is applied. The wrapped sqlx error means a connection could not be acquired: database unreachable, pool exhausted, or a dropped connection. The observation is lost unless the caller retries it.","triggerScenarios":"A burst of receipt observations exhausting the pool while broadcasting; database restart mid-observation; acquire_timeout shorter than the contention window.","commonSituations":"High transaction throughput with many concurrent watchers; undersized pools relative to watcher concurrency.","solutions":["Verify database health and retry the observation - record_execution_status is idempotent via its transition keys","Size the pool for peak watcher concurrency","Buffer and reorder observations rather than dropping them on acquisition failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match db.record_execution_status(intent_id, &tx_hash, status, block, hash, success, gas, price).await {\n    Err(e) if e.downcast_ref::<sqlx::Error>().is_some_and(|se| matches!(se, sqlx::Error::PoolTimedOut | sqlx::Error::Io(_))) => {\n        // queue the observation and retry; record_execution_status is idempotent by transition key\n    }\n    other => other?,\n}","preventionTips":["Queue receipt observations durably so pool exhaustion does not drop them","Size the pool for peak watcher concurrency, not average load","Exploit the idempotent transition keys: re-recording the same observation is safe"],"tags":["rust","sqlx","postgresql","connection-pool","receipt","status-transition"],"backgroundTag":"database-connection-failed","analyzedSha":"2114cf6f761429e0adb5ca9596fcd7b895b16011","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}