{"record":{"id":"97fcb86a539ef9e2","repo":"nautechsystems/nautilus_trader","slug":"execution-intent-intent-id-has-more-than-one-cur","errorCode":null,"errorMessage":"Execution intent {intent_id} has more than one current hash","messagePattern":"Execution intent (.+?) has more than one current hash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":3605,"sourceCode":"}\n\nfn validate_payload_operation_batch_size(batch_size: usize) -> anyhow::Result<i64> {\n    anyhow::ensure!(\n        (1..=MAX_PAYLOAD_OPERATION_BATCH_SIZE).contains(&batch_size),\n        \"Payload operation batch size must be between 1 and {MAX_PAYLOAD_OPERATION_BATCH_SIZE}\"\n    );\n    Ok(i64::try_from(batch_size).expect(\"bounded payload batch size fits i64\"))\n}\n\nfn current_execution_hash(\n    intent_id: i64,\n    hashes: &[ExecutionTransactionHashRow],\n) -> anyhow::Result<&ExecutionTransactionHashRow> {\n    let mut current = hashes.iter().filter(|row| row.current);\n    let row = current\n        .next()\n        .ok_or_else(|| anyhow::anyhow!(\"Execution intent {intent_id} has no current hash\"))?;\n    anyhow::ensure!(\n        current.next().is_none(),\n        \"Execution intent {intent_id} has more than one current hash\"\n    );\n    Ok(row)\n}\n\nfn open_execution_payload(\n    keys: &PayloadKeySet,\n    policy: PayloadPolicy,\n    intent: &ExecutionIntentRow,\n    hash: &ExecutionTransactionHashRow,\n    reason: &str,\n) -> anyhow::Result<Vec<u8>> {\n    anyhow::ensure!(\n        hash.payload_expected,\n        \"Execution transaction {} has no signed payload\",\n        hash.transaction_hash\n    );","sourceCodeStart":3587,"sourceCodeEnd":3623,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L3587-L3623","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Add or repair a partial unique index on (intent_id) WHERE current so the database prevents multiple current rows.","Fix the writer that rotates hash rows so it demarcates current atomically (single transaction).","Re-run/rebuild the intent pipeline for the affected intent if the row history is unrecoverable."],"exampleFix":"// before: two rows with current = true for the intent\nUPDATE execution_transaction_hashes\nSET current = false\nWHERE intent_id = '0xabc' AND transaction_hash = '0xold';\n\n// after: exactly one current row remains\n-- plus, prevent recurrence:\nCREATE UNIQUE INDEX one_current_hash_per_intent\n  ON execution_transaction_hashes (intent_id) WHERE current;","handlingStrategy":"validation","validationCode":"let current: Vec<_> = hashes.iter().filter(|row| row.current).collect();\nif current.len() != 1 {\n    // repair or reject before calling the resolver\n    anyhow::bail!(\"intent {} has {} current hash rows\", intent_id, current.len());\n}","typeGuard":"fn has_single_current(hashes: &[ExecutionTransactionHashRow]) -> bool {\n    hashes.iter().filter(|r| r.current).count() == 1\n}","tryCatchPattern":null,"preventionTips":["Enforce a partial unique index on (intent_id) WHERE current in the database.","Rotate the current flag inside a single DB transaction.","Monitor for intents with duplicate current rows with a periodic data-integrity query."],"tags":["database","invariant-violation","duplicate-rows"],"backgroundTag":"internal-invariant-violation","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"}