{"record":{"id":"14a3583c890da0b0","repo":"risingwavelabs/risingwave","slug":"internal-error-entered-unreachable-code-14a358","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/plan_node/mod.rs","lineNumber":89,"sourceCode":"    type PlanNodeType;\n\n    fn as_share(plan: &Self::PlanRefDyn) -> Option<&Self::ShareNode>;\n}\n\npub trait ShareNode<C: ConventionMarker>:\n    AnyPlanNodeMeta<C> + PlanTreeNodeUnary<C> + 'static\n{\n    fn share_id(&self) -> ShareId;\n    fn new_share(share: generic::Share<PlanRef<C>>) -> PlanRef<C>;\n    fn replace_input(&self, plan: PlanRef<C>) -> PlanRef<C>;\n    fn fork_with_input(&self, plan: PlanRef<C>) -> PlanRef<C>;\n}\n\npub struct NoShareNode<C: ConventionMarker>(!, PhantomData<C>);\n\nimpl<C: ConventionMarker> ShareNode<C> for NoShareNode<C> {\n    fn share_id(&self) -> ShareId {\n        unreachable!()\n    }\n\n    fn new_share(_plan: generic::Share<PlanRef<C>>) -> PlanRef<C> {\n        unreachable!()\n    }\n\n    fn replace_input(&self, _plan: PlanRef<C>) -> PlanRef<C> {\n        unreachable!()\n    }\n\n    fn fork_with_input(&self, _plan: PlanRef<C>) -> PlanRef<C> {\n        unreachable!()\n    }\n}\n\nimpl<C: ConventionMarker> PlanTreeNodeUnary<C> for NoShareNode<C> {\n    fn input(&self) -> PlanRef<C> {\n        unreachable!()","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/plan_node/mod.rs#L71-L107","documentation":"`NoShareNode` is a placeholder type used for plan conventions that do not support sharing (Common Subplan Elimination). Its `share_id` is `unreachable!()`: calling it panics with \"internal error: entered unreachable code\". It means code asked a convention that has no share support for a share id, which should be impossible if the optimizer only queries share_id on share-capable conventions.","triggerScenarios":"Invoking `share_id()` on a `PlanRef` whose convention resolves to `NoShareNode` (e.g. batch or other non-share conventions); generic optimizer code that unconditionally calls `share_id` without checking that the convention supports shares.","commonSituations":"Adding a generic pass that iterates all plan nodes and calls share_id; incorrectly wiring a convention's ShareNode impl to NoShareNode; refactoring conventions and forgetting to gate share-specific logic.","solutions":["Only call `share_id()` on nodes/conventions where the ShareNode trait is implemented by a real share type, not NoShareNode.","Gate share-specific optimizer logic behind a capability check or trait bound that excludes NoShareNode conventions.","If you need sharing for a new convention, implement a real ShareNode instead of using NoShareNode."],"exampleFix":"// before\nlet id = plan.share_id();\n// after\nif let Some(share) = plan.as_logical_share() {\n    let id = share.share_id();\n}","handlingStrategy":"type-guard","validationCode":"// Rust: only query share_id on share-capable conventions\nif plan.as_logical_share().is_some() { /* safe to call share_id */ }","typeGuard":"fn has_share_support<C: ConventionMarker>(_p: &PlanRef<C>) -> bool { !std::any::TypeId::of::<C::ShareNode>().implements::<NoShareNode>() /* or a capability const */ }","tryCatchPattern":"// Rust panics abort the thread; avoid by gating calls.\nif let Some(share) = plan.as_logical_share() { let id = share.share_id(); }","preventionTips":["Gate share-specific logic behind convention capability checks.","Add compile-time markers distinguishing share-capable conventions.","Review generic passes that touch share_id for NoShareNode coverage."],"tags":["unreachable","optimizer","rust","panic"],"backgroundTag":"internal-invariant-violation","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"}