nautechsystems/nautilus_trader · error

Execution intent has more than one current hash

Error message

Execution intent {intent_id} has more than one current hash

What it means

While resolving the current transaction hash row for an execution intent, the code expects exactly one row flagged `current`. If two or more rows are marked current, the database state for that intent is inconsistent and the library refuses to pick an arbitrary one. This invariant guards against broadcasting or signing against an ambiguous transaction hash.

Solutions

  1. Find the duplicate rows: SELECT * FROM execution_transaction_hashes WHERE intent_id = '<id>' AND current = true, and clear/merge the stale ones so exactly one remains.
  2. Add or repair a partial unique index on (intent_id) WHERE current so the database prevents multiple current rows.
  3. Fix the writer that rotates hash rows so it demarcates current atomically (single transaction).
  4. Re-run/rebuild the intent pipeline for the affected intent if the row history is unrecoverable.

Example fix

// before: two rows with current = true for the intent
UPDATE execution_transaction_hashes
SET current = false
WHERE intent_id = '0xabc' AND transaction_hash = '0xold';

// after: exactly one current row remains
-- plus, prevent recurrence:
CREATE UNIQUE INDEX one_current_hash_per_intent
  ON execution_transaction_hashes (intent_id) WHERE current;
Defensive patterns

Strategy: validation

Validate before calling

let current: Vec<_> = hashes.iter().filter(|row| row.current).collect();
if current.len() != 1 {
    // repair or reject before calling the resolver
    anyhow::bail!("intent {} has {} current hash rows", intent_id, current.len());
}

Type guard

fn has_single_current(hashes: &[ExecutionTransactionHashRow]) -> bool {
    hashes.iter().filter(|r| r.current).count() == 1
}

Prevention

When it happens

Trigger: Calling the hash-resolution helper with a `hashes` slice containing more than one `ExecutionTransactionHashRow` whose `current` flag is true, typically fetched from the execution transaction hash table for a single intent_id.

Common situations: Concurrent writers both inserting/updating hash rows without a uniqueness constraint on (intent_id, current=true); a failed or retried migration that duplicated rows; manual DB edits; a bug in the hash-rotation logic that flips current flags but forgets to clear the previous one.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

}

fn validate_payload_operation_batch_size(batch_size: usize) -> anyhow::Result<i64> {
    anyhow::ensure!(
        (1..=MAX_PAYLOAD_OPERATION_BATCH_SIZE).contains(&batch_size),
        "Payload operation batch size must be between 1 and {MAX_PAYLOAD_OPERATION_BATCH_SIZE}"
    );
    Ok(i64::try_from(batch_size).expect("bounded payload batch size fits i64"))
}

fn current_execution_hash(
    intent_id: i64,
    hashes: &[ExecutionTransactionHashRow],
) -> anyhow::Result<&ExecutionTransactionHashRow> {
    let mut current = hashes.iter().filter(|row| row.current);
    let row = current
        .next()
        .ok_or_else(|| anyhow::anyhow!("Execution intent {intent_id} has no current hash"))?;
    anyhow::ensure!(
        current.next().is_none(),
        "Execution intent {intent_id} has more than one current hash"
    );
    Ok(row)
}

fn open_execution_payload(
    keys: &PayloadKeySet,
    policy: PayloadPolicy,
    intent: &ExecutionIntentRow,
    hash: &ExecutionTransactionHashRow,
    reason: &str,
) -> anyhow::Result<Vec<u8>> {
    anyhow::ensure!(
        hash.payload_expected,
        "Execution transaction {} has no signed payload",
        hash.transaction_hash
    );

View on GitHub (pinned to 18893faf8b)