{"record":{"id":"b050b02653577dda","repo":"risingwavelabs/risingwave","slug":"fragment-not-found-in-previous-state","errorCode":null,"errorMessage":"fragment {} not found in previous state","messagePattern":"fragment (.+?) not found in previous state","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/src/stream/scale.rs","lineNumber":872,"sourceCode":"            let downstream_fragments = all_downstream_fragments\n                .remove(&(*fragment_id as FragmentId))\n                .unwrap_or_default();\n\n            let fragment_actors: HashMap<_, _> = upstream_fragments\n                .keys()\n                .copied()\n                .chain(downstream_fragments.keys().copied())\n                .map(|fragment_id| {\n                    all_prev_fragments\n                        .get(&fragment_id)\n                        .map(|fragment| {\n                            (\n                                fragment_id,\n                                fragment.actors.keys().copied().collect::<HashSet<_>>(),\n                            )\n                        })\n                        .ok_or_else(|| {\n                            MetaError::from(anyhow!(\n                                \"fragment {} not found in previous state\",\n                                fragment_id\n                            ))\n                        })\n                })\n                .collect::<MetaResult<_>>()?;\n\n            all_fragment_actors.extend(fragment_actors);\n\n            let source_fragment_actors = actors\n                .iter()\n                .map(|(actor_id, info)| (*actor_id, info.vnode_bitmap.clone()))\n                .collect();\n\n            let mut all_actor_dispatchers: HashMap<_, Vec<_>> = HashMap::new();\n\n            for downstream_fragment_id in downstream_fragments.keys() {\n                let target_fragment_actors =","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/meta/src/stream/scale.rs#L854-L890","documentation":"While assembling per-fragment actor sets, `build_reschedule_commands` looks up each fragment in `all_prev_fragments` to obtain its current actor ids. A fragment referenced by the plan but missing from the previous-state snapshot is an unrecoverable inconsistency, so it returns this error. It guarantees the reschedule diff operates on fragments the job actually has.","triggerScenarios":"Calling `build_reschedule_from_context` where a fragment id being diffed (from the reschedule diff or rendered output) has no entry in `all_prev_fragments` — e.g. a fragment created/deleted by a concurrent schema change between snapshot collection and diff computation.","commonSituations":"Race between `ALTER TABLE`/refresh and a reschedule on the same job; passing a context built for a different job version; catalog state changed since the context snapshot was captured.","solutions":["Retry the reschedule once concurrent DDL on the job has settled so the snapshot matches current state.","Rebuild the context, ensuring `all_prev_fragments` is refreshed atomically with the diff inputs.","Check the logged fragment_id against the job's fragments to find where the stale reference originates.","Serialize DDL and reschedule operations on the same job to avoid snapshot/version skew."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match build_reschedule_from_context(ctx).await {\n    Err(e) if e.to_string().contains(\"not found in previous state\") => {\n        // snapshot drift: rebuild and retry once\n        let fresh_ctx = rebuild_context().await?;\n        build_reschedule_from_context(fresh_ctx).await\n    }\n    r => r,\n}","preventionTips":["Serialize DDL and reschedule operations on the same streaming job.","Refresh the context snapshot immediately before computing the reschedule plan.","Alert on repeated occurrences — they indicate DDL/reschedule races in tooling."],"tags":["reschedule","fragment","scale"],"backgroundTag":"entity-not-found","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"}