{"record":{"id":"f858bccc60ef88c7","repo":"databendlabs/databend","slug":"unreachable-f858bc","errorCode":null,"errorMessage":"unreachable!()","messagePattern":"unreachable!\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_aggregate_serializer.rs","lineNumber":123,"sourceCode":"\n            if self.output_data.is_none() {\n                self.input_data = None;\n            }\n        }\n\n        Ok(())\n    }\n}\n\nimpl TransformAggregateSerializer {\n    fn transform_input_data(&mut self, mut data_block: DataBlock) -> Result<Event> {\n        debug_assert!(data_block.is_empty());\n\n        let Some(AggregateMeta::AggregatePayload(p)) = data_block\n            .take_meta()\n            .and_then(AggregateMeta::downcast_from)\n        else {\n            unreachable!()\n        };\n\n        self.input_data = Some(SerializeAggregateStream::create(&self.params, p));\n        Ok(Event::Sync)\n    }\n}\n\npub struct SerializeAggregateStream {\n    _params: Arc<AggregatorParams>,\n    payload: AggregatePayload,\n    flush_state: PayloadFlushState,\n    end_iter: bool,\n    nums: usize,\n}\n\nunsafe impl Send for SerializeAggregateStream {}\n\nunsafe impl Sync for SerializeAggregateStream {}","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_aggregate_serializer.rs#L105-L141","documentation":"TransformAggregateSerializer::transform_input_data expects every non-empty input block to carry AggregateMeta::AggregatePayload so it can build a SerializeAggregateStream. If take_meta/downcast fails, the code calls unreachable!(), aborting because the serializer was fed a block shape it cannot serialize. It is a pipeline-internal invariant check, not user input validation.","triggerScenarios":"event() -> transform_input_data receives a block whose meta is not AggregateMeta::AggregatePayload (e.g. it is Partitioned, spilled meta, or empty-with-wrong-meta), usually after pipeline rewiring, mixed cluster versions, or a bug in the transform upstream that attaches the wrong meta variant.","commonSituations":"Rolling upgrades with mismatched node versions exchanging aggregate payloads; custom transforms inserted between partial aggregation and the serializer; regressions from refactoring AggregateMeta enum variants.","solutions":["Ensure all cluster nodes run the same Databend version and rerun the query","Inspect the upstream transform feeding TransformAggregateSerializer to confirm it emits AggregatePayload meta","If a custom pipeline is involved, only pass blocks with AggregateMeta::AggregatePayload to this serializer","File a bug with query profile/plan if reproducible on identical versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check before the serializer transform\nfn has_aggregate_payload(block: &DataBlock) -> bool {\n    block.get_meta()\n        .and_then(AggregateMeta::downcast_ref_from)\n        .map(|m| matches!(m, AggregateMeta::AggregatePayload(_)))\n        .unwrap_or(false)\n}","typeGuard":"fn as_aggregate_payload(m: Option<&Arc<DataBlockMeta>>) -> Option<&AggregatePayload> {\n    m.and_then(AggregateMeta::downcast_ref_from)\n        .and_then(|m| match m {\n            AggregateMeta::AggregatePayload(p) => Some(p),\n            _ => None,\n        })\n}","tryCatchPattern":"match res {\n    Err(e) if e.message().contains(\"unreachable\") && pipeline_stage == \"aggregate_serializer\" => {\n        // abort query, verify node versions, file bug with stack trace\n    }\n    ...\n}","preventionTips":["Run homogeneous cluster versions during distributed aggregation","Never insert custom transforms between partial aggregation and the serializer that alter meta","Add a unit test asserting upstream blocks carry AggregatePayload meta","Keep AggregateMeta enum refactors synchronized across serde transforms"],"tags":["internal","aggregation","serde","unreachable"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}