{"record":{"id":"d7a567e3868e7da1","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-marker-exists-without-durable-st","errorCode":null,"errorMessage":"Execution payload marker exists without durable state","messagePattern":"Execution payload marker exists without durable state","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":4625,"sourceCode":"    }\n\n    /// Activates or resumes protected signed-transaction storage for this database.\n    pub(crate) async fn ensure_execution_payload_storage(\n        &self,\n        keys: &PayloadKeySet,\n    ) -> anyhow::Result<()> {\n        let marker = self.execution_payload_marker().await?;\n        match marker {\n            None => self.activate_execution_payload_storage(keys).await?,\n            Some(version) => anyhow::ensure!(\n                version == EXECUTION_PAYLOAD_PROTOCOL_VERSION,\n                \"Execution payload protection version {version} is newer than supported version {EXECUTION_PAYLOAD_PROTOCOL_VERSION}\"\n            ),\n        }\n\n        loop {\n            let state = self.execution_payload_state().await?.ok_or_else(|| {\n                anyhow::anyhow!(\"Execution payload marker exists without durable state\")\n            })?;\n            validate_execution_payload_state(&state, keys)?;\n            match state.operation.as_str() {\n                \"migrate\" => {\n                    if self\n                        .migrate_execution_payload_batch(keys, EXECUTION_PAYLOAD_BATCH_SIZE)\n                        .await?\n                    {\n                        break;\n                    }\n                }\n                \"ready\" => break,\n                operation => anyhow::bail!(\n                    \"Execution payload storage is in {operation} maintenance; complete or roll back that operation before connecting\"\n                ),\n            }\n        }\n","sourceCodeStart":4607,"sourceCodeEnd":4643,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L4607-L4643","documentation":"In `ensure_execution_payload_storage`, after confirming the schema-version marker exists, the durable `execution_payload_state` row must also exist. If the marker is present but the state row is missing, storage is in an inconsistent half-initialized state and this invariant-violation error is thrown instead of proceeding.","triggerScenarios":"`execution_payload_state()` returns None while the marker row exists — e.g. someone deleted the `execution_payload_state` row for component 'signed_transactions', a partial manual cleanup removed state but not the version marker, or activation crashed in a way that committed the marker outside the state transaction.","commonSituations":"Manual DB surgery / cleanup scripts deleting rows; restoring a partial backup; an operator trying to 'reset' payload protection by deleting state rows.","solutions":["Re-create the durable state by running the activation path from a clean database (drop the payload tables and marker, then restart so activation re-runs)","Restore the missing execution_payload_state row from a backup taken while storage was healthy","Never delete state rows manually; use the library's own rollback/complete maintenance flow","Compare the current row set against a healthy database to identify what else is missing"],"exampleFix":"// before: manual removal breaks the invariant\nDELETE FROM execution_payload_state WHERE component = 'signed_transactions';\n// after: reset properly so activation re-runs\nDELETE FROM execution_payload_state WHERE component = 'signed_transactions';\nDELETE FROM execution_schema_version WHERE component = '<payload component>';","handlingStrategy":"validation","validationCode":"let marker: Option<i16> = sqlx::query_scalar(\n    \"SELECT version FROM execution_schema_version WHERE component = $1\")\n    .bind(EXECUTION_PAYLOAD_COMPONENT).fetch_optional(&pool).await?;\nlet state: Option<()> = sqlx::query_scalar(\n    \"SELECT 1 FROM execution_payload_state WHERE component = 'signed_transactions'\")\n    .fetch_optional(&pool).await?;\nif marker.is_some() && state.is_none() {\n    return Err(anyhow::anyhow!(\"marker present but state row missing; restore from backup or re-activate from clean state\"));\n}","typeGuard":"fn storage_consistent(marker: Option<i16>, state_row: Option<impl Sized>) -> bool {\n    marker.is_some() == state_row.is_some()\n}","tryCatchPattern":"match db.ensure_execution_payload_storage(&keys).await {\n    Err(e) if e.to_string().contains(\"marker exists without durable state\") => {\n        // halt node: storage is half-initialized; restore backup or reset both marker and state\n        return Err(e.context(\"manual DB cleanup detected; re-provision payload storage\"));\n    }\n    other => other?,\n}","preventionTips":["Never delete execution_payload_state rows manually; use the library's reset/rollback flow","Restore full backups, not selective table restores","Treat the marker and state row as a single logical unit","Audit cleanup scripts against library-owned tables"],"tags":["invariant","postgres","state-corruption"],"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-14T05:17:10.506Z"}