{"record":{"id":"8be15eac0079f94c","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-migration-state-is-missing","errorCode":null,"errorMessage":"Execution payload migration state is missing","messagePattern":"Execution payload migration state is missing","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4912,"sourceCode":"    ) -> anyhow::Result<bool> {\n        anyhow::ensure!(\n            batch_size > 0,\n            \"Execution payload batch size must be positive\"\n        );\n        let mut transaction = self\n            .pool\n            .begin()\n            .await\n            .context(\"failed to start execution payload migration batch\")?;\n        lock_execution_payload_operation(&mut transaction).await?;\n        let state_row = sqlx::query(\n            \"SELECT deployment_id, protocol_version, operation, active_key_id \\\n             FROM execution_payload_state WHERE component = 'signed_transactions' FOR UPDATE\",\n        )\n        .fetch_optional(&mut *transaction)\n        .await\n        .context(\"failed to lock execution payload migration state\")?\n        .ok_or_else(|| anyhow::anyhow!(\"Execution payload migration state is missing\"))?;\n        let state = execution_payload_state_from_row(&state_row)?;\n        validate_execution_payload_state(&state, keys)?;\n        anyhow::ensure!(\n            state.operation == \"migrate\",\n            \"Execution payload storage is {}, not migrating\",\n            state.operation\n        );\n\n        let rows = sqlx::query_as::<_, ExecutionTransactionHashRow>(\n            \"\n            SELECT\n                id, intent_id, chain_id, transaction_hash, payload_expected,\n                raw_transaction, sealed_transaction, status, block_number, block_hash,\n                receipt_success, gas_used, effective_gas_price, current\n            FROM execution_transaction_hash\n            WHERE payload_expected AND raw_transaction IS NOT NULL\n            ORDER BY id\n            LIMIT $1","sourceCodeStart":4894,"sourceCodeEnd":4930,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L4894-L4930","documentation":"migrate_execution_payload_batch locks the execution_payload_state row FOR UPDATE and requires it to exist, since migration state (deployment, keys, operation) lives there. A missing row means the store is not in a migration-capable protected state, so the batch step cannot proceed safely.","triggerScenarios":"Calling migrate_execution_payload_batch when execution_payload_state has no row for component 'signed_transactions' — protection never activated, or the state row was deleted/corrupted before migration started.","commonSituations":"Running the migration tool against a fresh database without activation; restoring a backup without the state row; pointing the migrator at the wrong database/schema.","solutions":["Activate protected payload storage first (the library's activation path seeds the state row and sets operation='migrate' before migrating)","Verify the state row exists before migrating: SELECT * FROM execution_payload_state WHERE component='signed_transactions'","Check that the migrator's connection string targets the intended database","Restore the state row from a consistent backup if lost"],"exampleFix":"// before: migrating an unactivated store\ndb.migrate_execution_payload_batch(&keys, 500).await?;\n// after: ensure activation/protection first\ndb.require_execution_payload_storage_ready(&keys).await?;","handlingStrategy":"validation","validationCode":"let state: Option<(String, String)> = sqlx::query_as(\n    \"SELECT deployment_id, operation FROM execution_payload_state WHERE component = 'signed_transactions'\",\n).fetch_optional(&pool).await?;\nif state.is_none() {\n    anyhow::bail!(\"activation required before migration\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = db.migrate_execution_payload_batch(&keys, 500).await {\n    if e.to_string().contains(\"migration state is missing\") {\n        db.require_execution_payload_storage_ready(&keys).await?; // then enter migration properly\n    } else { return Err(e); }\n}","preventionTips":["Run activation as an explicit setup step in every environment","Verify connection strings target the intended database before running migrations","Never delete execution_payload_state rows","Restore full, consistent backups only"],"tags":["database","migration","state"],"backgroundTag":"resource-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}