risingwavelabs/risingwave · error

dag cache is only used for shares

Error message

dag cache is only used for shares

What it means

Panic (expect) in merge_eq_nodes' Counter::visited: the DAG-counting visitor assumes every visited plan node is a LogicalShare, since dag_visit is only invoked on share nodes. Encountering a non-share node means the visitor was driven over a plan that violates this invariant, so it panics with this message instead of returning an error.

Solutions

  1. This is an invariant violation in the DAG-visit utility: Counter::visited was called on a plan node without a LogicalShare. Ensure dag_visit is only invoked on plans that have been shared/rewritten.
  2. Report as a bug with the plan/query that triggered it.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs:98 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs:98

}

impl Counter {
    fn to_pruner(&self) -> Pruner<'_> {
        Pruner {
            counts: &self.counts,
            cache: HashMap::new(),
        }
    }
}

impl VisitPlan for Counter {
    fn visited<F>(&mut self, plan: &PlanRef, mut f: F)
    where
        F: FnMut(&mut Self),
    {
        let share_id = plan
            .as_logical_share()
            .expect("dag cache is only used for shares")
            .share_id();
        if self.counts.get(&share_id).is_none_or(|c| *c <= 1) {
            f(self);
        }
    }
}

impl Visit<PlanRef> for Counter {
    fn visit(&mut self, t: &PlanRef) {
        if let Some(s) = t.as_logical_share() {
            self.counts
                .entry(s.share_id())
                .and_modify(|c| *c += 1)
                .or_insert(1);
        }
        self.dag_visit(t);
    }
}

View on GitHub (pinned to 6469eb736d)