risingwavelabs/risingwave · error · MetaError

failed to find fragment: {}

Error message

failed to find fragment: {}

What it means

The closure load_fragment_distribution_type queries the fragment table for the distribution type of a given fragment id; if the query returns no row it raises MetaError::from(anyhow!("failed to find fragment: {}")), i.e. a fragment the backfill rewrite depends on does not exist in the meta database.

Source

Thrown at src/meta/src/controller/fragment.rs:1768

                    source_backfill_fragment_id
                )
            })?;

        if fragment_relation != DispatcherType::NoShuffle {
            return Err(anyhow!("expected NoShuffle but got {:?}", fragment_relation).into());
        }

        let load_fragment_distribution_type = |txn, fragment_id: FragmentId| async move {
            let result: MetaResult<DistributionType> = try {
                FragmentModel::find_by_id(fragment_id)
                    .select_only()
                    .column(fragment::Column::DistributionType)
                    .into_tuple()
                    .one(txn)
                    .await
                    .map_err(MetaError::from)?
                    .ok_or_else(|| {
                        MetaError::from(anyhow!("failed to find fragment: {}", fragment_id))
                    })?
            };
            result
        };

        let source_backfill_distribution_type =
            load_fragment_distribution_type(&txn, source_backfill_fragment_id).await?;
        let source_distribution_type =
            load_fragment_distribution_type(&txn, source_fragment_id).await?;

        let load_fragment_actor_distribution =
            |actor_info: &SharedActorInfos,
             fragment_id: FragmentId|
             -> HashMap<crate::model::ActorId, Option<Bitmap>> {
                let guard = actor_info.read_guard();

                guard
                    .get_fragment(fragment_id as _)

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Verify the fragment row exists: query the fragment table for the reported fragment_id
  2. Check whether the owning streaming job was concurrently dropped and retry or abandon the rewrite accordingly
  3. If a partial write occurred (relations present, fragments missing), restore meta data from a consistent backup
  4. File an issue with the meta logs if stock DDL leaves orphaned relation rows
Defensive patterns

Strategy: validation

Validate before calling

let n = Fragment::find().filter(fragment::Column::FragmentId.eq(fid)).count(&db).await?;
if n == 0 { return Err(fragment_missing(fid)); }

Try / catch

match get_job_fragments_by_id(job_id).await { Err(e) if e.to_string().contains("failed to find fragment") => handle_partial_metadata(job_id), other => other }

Prevention

When it happens

Trigger: Running source backfill rewrite when source_backfill_fragment_id (or the source fragment) has no row in the fragment table — partial fragment persistence, concurrent drop of the job, or ids pointing at fragments from a dropped/recreated table.

Common situations: Interrupted DDL leaving relation rows without fragment rows; querying a job mid-drop; meta store restored from an inconsistent backup; version migration gaps.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/4418e5498d97e034. Report an issue: GitHub.