{"record":{"id":"666ca72779ef3996","repo":"risingwavelabs/risingwave","slug":"invalid-backfill-state-row-count","errorCode":null,"errorMessage":"invalid backfill state: row_count","messagePattern":"invalid backfill state: row_count","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/executor/backfill/cdc/state.rs","lineNumber":74,"sourceCode":"    }\n\n    /// Restore the backfill state from storage\n    pub async fn restore_state(&mut self) -> StreamExecutorResult<CdcStateRecord> {\n        let key = Some(self.split_id.clone());\n        match self\n            .state_table\n            .get_row(row::once(key.map(ScalarImpl::from)))\n            .await?\n        {\n            Some(row) => {\n                tracing::info!(\"restored cdc backfill state: {:?}\", row);\n                self.cached_state = row.into_inner().into_vec();\n                let state = self.cached_state.as_slice();\n                let state_len = state.len();\n                // schema: | `split_id` | `pk...` | `backfill_finished` | `row_count` | `cdc_offset` |\n                let row_count = match state[state_len - 2] {\n                    Some(ScalarImpl::Int64(val)) => val,\n                    _ => return Err(anyhow!(\"invalid backfill state: row_count\").into()),\n                };\n                let is_finished = match state[state_len - 3] {\n                    Some(ScalarImpl::Bool(val)) => val,\n                    _ => return Err(anyhow!(\"invalid backfill state: backfill_finished\").into()),\n                };\n                let cdc_offset = match state[state_len - 1] {\n                    Some(ScalarImpl::Jsonb(ref jsonb)) => {\n                        serde_json::from_value(jsonb.clone().take()).unwrap()\n                    }\n                    None if is_finished => None,\n                    None => {\n                        return Err(anyhow!(\n                            \"invalid backfill state: unfinished row has null cdc_offset\"\n                        )\n                        .into());\n                    }\n                    _ => return Err(anyhow!(\"invalid backfill state: cdc_offset\").into()),\n                };","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/executor/backfill/cdc/state.rs#L56-L92","documentation":"The CDC backfill state row follows the schema `| split_id | pk... | backfill_finished | row_count | cdc_offset |`. `restore_state` requires `row_count` (second-to-last column) to be a non-NULL Int64; anything else means the persisted backfill state is invalid and recovery aborts with this error.","triggerScenarios":"Recovering a CDC backfill executor whose persisted state row has a NULL or non-Int64 `row_count` column — incomplete state write before a crash, schema drift, or corrupted state table.","commonSituations":"Crash during CDC backfill state commit, RisingWave upgrades changing state schema, or manually modified/corrupted state store rows.","solutions":["Drop and re-create the CDC table (or the materialized/source using CDC backfill) to rebuild state from scratch.","Confirm writer and reader RisingWave versions match; if an upgrade happened, rebuild rather than recover.","Inspect the state row (schema shown in the error context) to confirm which column is malformed.","Restore the state table from a known-good backup/snapshot if available."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-create CDC tables after upgrading RisingWave instead of recovering old state.","Ensure clean shutdowns so backfill state rows are written atomically.","Back up state store before maintenance on backfilling tables."],"tags":["streaming","cdc","backfill","state","recovery"],"backgroundTag":"schema-validation-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}