{"record":{"id":"25406f5b726a20e7","repo":"nautechsystems/nautilus_trader","slug":"failed-to-persist-broadcast-attempt-for-transactio","errorCode":null,"errorMessage":"Failed to persist broadcast attempt for transaction {tx_hash}: {e}; the in-flight slot stays occupied","messagePattern":"Failed to persist broadcast attempt for transaction (.+?): (.+?); the in-flight slot stays occupied","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":3240,"sourceCode":"    }\n\n    async fn broadcast(&self, prepared: &PreparedTransaction) -> anyhow::Result<BroadcastOutcome> {\n        let tx_hash = prepared.tx_hash;\n\n        self.database\n            .record_execution_status(\n                prepared.intent_id,\n                &tx_hash.to_string(),\n                TransactionStatus::Broadcast,\n                None,\n                None,\n                None,\n                None,\n                None,\n            )\n            .await\n            .map_err(|e| {\n                anyhow::anyhow!(\n                    \"Failed to persist broadcast attempt for transaction {tx_hash}: {e}; the in-flight slot stays occupied\"\n                )\n            })?;\n\n        match self\n            .http_rpc_client\n            .send_raw_transaction(&prepared.raw_tx, &tx_hash)\n            .await\n        {\n            Ok(broadcast_hash) => {\n                if broadcast_hash != tx_hash {\n                    // The node acknowledged a different hash: acceptance of the signed\n                    // transaction is unverified, so reconcile through the persisted record\n                    // rather than poll a hash that cannot match the chain\n                    return Ok(BroadcastOutcome::Ambiguous(format!(\n                        \"Broadcast of transaction {tx_hash} returned a differing hash {broadcast_hash}; the persisted record reconciles instead of rebroadcasting\"\n                    )));\n                }","sourceCodeStart":3222,"sourceCodeEnd":3258,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L3222-L3258","documentation":"Before broadcasting, the client persists a broadcast-attempt record for the transaction; if that database write fails, the in-flight nonce slot cannot be safely released or accounted for, so the error is raised with the slot intentionally left occupied. This prevents rebroadcasting a nonce whose persistence state is unknown.","triggerScenarios":"The persist_broadcast_attempt database call failed (connection loss, constraint violation, disk full, lock timeout) while recording the attempt for tx_hash; the slot for that nonce stays occupied until the record is written.","commonSituations":"Postgres/DB outage or connection pool exhaustion during broadcast; disk full; schema migration mismatch; concurrent writer holding locks on the execution tables.","solutions":["Restore database connectivity and re-run reconciliation; the occupied slot will be resolved once the attempt persists","Check DB health: connection limits, disk space, lock contention on execution tables","Verify the broadcast-attempt table schema matches the client's manifest_version","If the transaction actually landed on-chain, reconciliation will detect it via the nonce/canonical scan once persistence recovers"],"exampleFix":"// before\npool = Pool::connect(\"postgres://...\", 1); // pool exhausted under load\n// after\npool = Pool::connect(\"postgres://...\", 32);\npool.set_acquire_timeout(Duration::from_secs(30));","handlingStrategy":"try-catch","validationCode":"db.ping().await?; // confirm DB reachable before broadcast\nif db.lock_contention_on(\"execution_broadcast_attempts\") { return Err(\"defer broadcast\"); }","typeGuard":null,"tryCatchPattern":"match persist_result {\n    Err(e) => {\n        warn!(\"broadcast attempt persistence failed ({e}); nonce slot stays occupied\");\n        keep_slot_occupied_and_retry_later();\n    }\n    Ok(_) => proceed_with_broadcast(),\n}","preventionTips":["Monitor DB health and pool saturation","Size connection pools for broadcast bursts","Version-check schema against manifest_version","Alert on failed broadcast-attempt writes since slots stay occupied"],"tags":["database","persistence","nonce","broadcast"],"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"}