nautechsystems/nautilus_trader · error

Failed to persist broadcast attempt for transaction

Error message

Failed to persist broadcast attempt for transaction {tx_hash}: {e}; the in-flight slot stays occupied

What it means

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.

Solutions

  1. Restore database connectivity and re-run reconciliation; the occupied slot will be resolved once the attempt persists
  2. Check DB health: connection limits, disk space, lock contention on execution tables
  3. Verify the broadcast-attempt table schema matches the client's manifest_version
  4. If the transaction actually landed on-chain, reconciliation will detect it via the nonce/canonical scan once persistence recovers

Example fix

// before
pool = Pool::connect("postgres://...", 1); // pool exhausted under load
// after
pool = Pool::connect("postgres://...", 32);
pool.set_acquire_timeout(Duration::from_secs(30));
Defensive patterns

Strategy: try-catch

Validate before calling

db.ping().await?; // confirm DB reachable before broadcast
if db.lock_contention_on("execution_broadcast_attempts") { return Err("defer broadcast"); }

Try / catch

match persist_result {
    Err(e) => {
        warn!("broadcast attempt persistence failed ({e}); nonce slot stays occupied");
        keep_slot_occupied_and_retry_later();
    }
    Ok(_) => proceed_with_broadcast(),
}

Prevention

When it happens

Trigger: 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.

Common situations: Postgres/DB outage or connection pool exhaustion during broadcast; disk full; schema migration mismatch; concurrent writer holding locks on the execution tables.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/25406f5b726a20e7. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/blockchain/src/execution/client.rs:3240

    }

    async fn broadcast(&self, prepared: &PreparedTransaction) -> anyhow::Result<BroadcastOutcome> {
        let tx_hash = prepared.tx_hash;

        self.database
            .record_execution_status(
                prepared.intent_id,
                &tx_hash.to_string(),
                TransactionStatus::Broadcast,
                None,
                None,
                None,
                None,
                None,
            )
            .await
            .map_err(|e| {
                anyhow::anyhow!(
                    "Failed to persist broadcast attempt for transaction {tx_hash}: {e}; the in-flight slot stays occupied"
                )
            })?;

        match self
            .http_rpc_client
            .send_raw_transaction(&prepared.raw_tx, &tx_hash)
            .await
        {
            Ok(broadcast_hash) => {
                if broadcast_hash != tx_hash {
                    // The node acknowledged a different hash: acceptance of the signed
                    // transaction is unverified, so reconcile through the persisted record
                    // rather than poll a hash that cannot match the chain
                    return Ok(BroadcastOutcome::Ambiguous(format!(
                        "Broadcast of transaction {tx_hash} returned a differing hash {broadcast_hash}; the persisted record reconciles instead of rebroadcasting"
                    )));
                }

View on GitHub (pinned to 18893faf8b)