{"record":{"id":"0b8bb54a94263eba","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-storage-is-marked-ready-without","errorCode":null,"errorMessage":"Execution payload storage is marked ready without its write fence or constraint","messagePattern":"Execution payload storage is marked ready without its write fence or constraint","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":5081,"sourceCode":"            \"SELECT deployment_id, protocol_version, operation, active_key_id \\\n             FROM execution_payload_state WHERE component = 'signed_transactions' FOR SHARE\",\n        )\n        .fetch_optional(&mut *transaction)\n        .await\n        .context(\"failed to lock execution payload state\")?\n        .ok_or_else(|| anyhow::anyhow!(\"Execution payload 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 == \"ready\",\n            \"Execution payload storage is not ready\"\n        );\n        let (payload_fence, payload_constraint) =\n            sqlx::query_as::<_, (bool, bool)>(EXECUTION_PAYLOAD_INFRASTRUCTURE_QUERY)\n                .fetch_one(&mut *transaction)\n                .await\n                .context(\"failed to inspect execution payload protection infrastructure\")?;\n        anyhow::ensure!(\n            payload_fence && payload_constraint,\n            \"Execution payload storage is marked ready without its write fence or constraint\"\n        );\n        validate_execution_payload_key_inventory(&mut transaction, keys).await?;\n        transaction\n            .commit()\n            .await\n            .context(\"failed to complete execution payload validation\")?;\n        Ok(())\n    }\n\n    pub(crate) async fn check_execution_payload_storage(\n        &self,\n        keys: Option<&PayloadKeySet>,\n        policy: Option<PayloadPolicy>,\n        batch_size: i64,\n    ) -> anyhow::Result<ExecutionPayloadCheck> {\n        let (check, transaction) = self","sourceCodeStart":5063,"sourceCodeEnd":5099,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L5063-L5099","documentation":"Even though the state row says operation='ready', the expected database protection infrastructure — the write fence and/or the constraint guarding execution payload tables — is absent. The code refuses to trust a 'ready' marker without the actual enforcement objects in place.","triggerScenarios":"State marked ready but a trigger/constraint was dropped manually; migration marked ready then infrastructure was removed; restoring a backup that contains the state row but not the constraint/trigger definitions.","commonSituations":"Schema drift from manual DB surgery; partial restore from backups; DB migrations from other tooling dropping constraints.","solutions":["Re-run the migration/setup step that creates the write fence and constraint","Re-add the missing constraint or trigger per the schema definitions in the codebase","Restore schema from a consistent backup","Audit who/what dropped the infrastructure before re-marking ready"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let (fence, constraint): (bool, bool) = sqlx::query_as(EXECUTION_PAYLOAD_INFRASTRUCTURE_QUERY).fetch_one(&mut conn).await?;\nif !(fence && constraint) { reapply_infrastructure(&mut conn).await?; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep schema objects (fence/constraint) under migration tooling, not manual SQL","Verify infrastructure after every restore","Restrict ALTER/DROP privileges on payload tables","Re-run setup whenever state says ready but checks fail"],"tags":["database","schema","invariant"],"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-14T00:17:10.932Z"}