{"record":{"id":"bbed819131c5a896","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-deployment-id-does-not-match-thi","errorCode":null,"errorMessage":"Execution payload deployment ID does not match this database","messagePattern":"Execution payload deployment ID does not match this database","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":7489,"sourceCode":") -> anyhow::Result<ExecutionPayloadState> {\n    Ok(ExecutionPayloadState {\n        deployment_id: row.try_get(\"deployment_id\")?,\n        protocol_version: row.try_get(\"protocol_version\")?,\n        operation: row.try_get(\"operation\")?,\n        active_key_id: row.try_get(\"active_key_id\")?,\n    })\n}\n\nfn validate_execution_payload_state(\n    state: &ExecutionPayloadState,\n    keys: &PayloadKeySet,\n) -> anyhow::Result<()> {\n    anyhow::ensure!(\n        state.protocol_version == EXECUTION_PAYLOAD_PROTOCOL_VERSION,\n        \"Execution payload protocol version {} is not supported\",\n        state.protocol_version\n    );\n    anyhow::ensure!(\n        state.deployment_id == keys.deployment_id(),\n        \"Execution payload deployment ID does not match this database\"\n    );\n    anyhow::ensure!(\n        state.active_key_id.as_slice() == keys.active_key_id(),\n        \"Configured active payload key does not match the database active key\"\n    );\n    Ok(())\n}\n\nasync fn lock_execution_payload_operation(\n    transaction: &mut Transaction<'_, Postgres>,\n) -> anyhow::Result<()> {\n    let lock = PgAdvisoryLock::new(\"nautilus:blockchain:execution-payload\");\n    let PgAdvisoryLockKey::BigInt(lock_key) = lock.key() else {\n        unreachable!(\"string advisory locks use the 64-bit key space\");\n    };\n    sqlx::query(\"SELECT pg_advisory_xact_lock($1)\")","sourceCodeStart":7471,"sourceCodeEnd":7507,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L7471-L7507","documentation":"This ensure! verifies that the deployment_id stored inside the loaded ExecutionPayloadState matches the deployment_id derived from the configured payload keys. The cache database is deployment-scoped; a payload from a different deployment must not be loaded. It prevents cross-deployment data confusion.","triggerScenarios":"Calling the payload load/validate path where the row's deployment_id differs from the deployment_id of the configured PayloadKeySet — e.g. reusing a cache database across two deployments.","commonSituations":"Copying a production cache DB into a staging environment; changing deployment configuration without a fresh database; pointing multiple deployments at one shared Postgres cache.","solutions":["Use a cache database dedicated to this deployment_id (create a new database or schema)","Restore the correct deployment configuration so keys.deployment_id() matches the stored data","Purge/rebuild the local cache if the old data is no longer needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if stored.deployment_id != configured_keys.deployment_id() {\n    return Err(\"cache database belongs to a different deployment\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision a dedicated database per deployment_id","Record deployment_id in deployment config and verify it at startup","Avoid copying cache databases between environments"],"tags":["database","configuration","rust","deployment"],"backgroundTag":"invalid-config-value","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"}