{"record":{"id":"1b3be736539bd7a9","repo":"risingwavelabs/risingwave","slug":"dag-cache-is-only-used-for-shares","errorCode":null,"errorMessage":"dag cache is only used for shares","messagePattern":"dag cache is only used for shares","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs","lineNumber":98,"sourceCode":"}\n\nimpl Counter {\n    fn to_pruner(&self) -> Pruner<'_> {\n        Pruner {\n            counts: &self.counts,\n            cache: HashMap::new(),\n        }\n    }\n}\n\nimpl VisitPlan for Counter {\n    fn visited<F>(&mut self, plan: &PlanRef, mut f: F)\n    where\n        F: FnMut(&mut Self),\n    {\n        let share_id = plan\n            .as_logical_share()\n            .expect(\"dag cache is only used for shares\")\n            .share_id();\n        if self.counts.get(&share_id).is_none_or(|c| *c <= 1) {\n            f(self);\n        }\n    }\n}\n\nimpl Visit<PlanRef> for Counter {\n    fn visit(&mut self, t: &PlanRef) {\n        if let Some(s) = t.as_logical_share() {\n            self.counts\n                .entry(s.share_id())\n                .and_modify(|c| *c += 1)\n                .or_insert(1);\n        }\n        self.dag_visit(t);\n    }\n}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs#L80-L116","documentation":"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.","triggerScenarios":"Thrown at src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["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.","Report as a bug with the plan/query that triggered it."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}