{"record":{"id":"be32611f9abfc314","repo":"databendlabs/databend","slug":"unexpected-aggregate-meta","errorCode":null,"errorMessage":"unexpected aggregate meta","messagePattern":"unexpected aggregate meta","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_exchange_aggregate_serializer.rs","lineNumber":194,"sourceCode":"                                StringType::from_data(location_column),\n                                BinaryType::from_data(row_group_column),\n                            ]);\n\n                            data_block.add_meta(Some(AggregateSerdeMeta::create_spilled(\n                                bucket_num as isize,\n                            )))?\n                        }\n                        PartitionedData::Mixed(data) => PartitionItem::serialize_mixed(data)?,\n                        data => {\n                            return Err(ErrorCode::Internal(format!(\n                                \"Partitioned meta cannot be serialized from this payload batch: {data:?}\"\n                            )));\n                        }\n                    };\n                    let serialized = serialize_block(-1, data_block, &self.options)?;\n                    serialized_blocks.push(serialized);\n                }\n                _ => unreachable!(\"unexpected aggregate meta\"),\n            };\n        }\n\n        Ok(vec![DataBlock::empty_with_meta(\n            ExchangeShuffleMeta::create(serialized_blocks),\n        )])\n    }\n}\n","sourceCodeStart":176,"sourceCodeEnd":203,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/pipelines/processors/transforms/aggregator/serde/transform_exchange_aggregate_serializer.rs#L176-L203","documentation":"TransformExchangeAggregateSerializer serializes AggregateMeta::Partitioned payloads for exchange and only matches the Partitioned variant; any other AggregateMeta variant hits unreachable!(\"unexpected aggregate meta\"). It asserts that only partitioned aggregate meta ever reaches this exchange serializer.","triggerScenarios":"transform() receives a block whose meta is AggregateMeta but not AggregateMeta::Partitioned (e.g. bare AggregatePayload or spilled meta), due to upstream pipeline mis-wiring, mixed node versions, or a regression in the partial aggregate transform.","commonSituations":"Rolling-upgrade version skew between nodes; custom pipelines attaching non-partitioned aggregate meta to blocks entering the shuffle exchange; bugs after refactoring AggregateMeta variants.","solutions":["Make all cluster nodes run the same version and rerun","Verify the transform feeding this serializer only emits AggregateMeta::Partitioned blocks","Replace with a descriptive internal error to aid debugging and file an issue with the query profile"],"exampleFix":"// before\n_ => unreachable!(\"unexpected aggregate meta\"),\n// after\nmeta => {\n    return Err(ErrorCode::Internal(format!(\n        \"unexpected aggregate meta in exchange serializer: {meta:?}\"\n    )));\n}","handlingStrategy":"try-catch","validationCode":"fn is_partitioned(m: Option<&Arc<DataBlockMeta>>) -> bool {\n    m.and_then(AggregateMeta::downcast_ref_from)\n        .map(|m| matches!(m, AggregateMeta::Partitioned { .. }))\n        .unwrap_or(false)\n}","typeGuard":"fn partitioned_meta(m: Option<&Arc<DataBlockMeta>>) -> Option<(&Option<isize>, &PartitionedData)> {\n    m.and_then(AggregateMeta::downcast_ref_from)\n        .and_then(|m| match m {\n            AggregateMeta::Partitioned { bucket, data } => Some((bucket, data)),\n            _ => None,\n        })\n}","tryCatchPattern":"match res {\n    Err(e) if e.message().contains(\"unexpected aggregate meta\") || panic_in(\"TransformExchangeAggregateSerializer\") => {\n        // verify version skew, abort and report with query profile\n    }\n    ...\n}","preventionTips":["Ensure only the partitioned-aggregate pipeline feeds the shuffle exchange serializer","Match cluster versions across all nodes","Convert such unreachable! sites into typed ErrorCode::Internal for debuggability","Add tests pinning AggregateMeta variants accepted by the serializer"],"tags":["internal","distributed-query","exchange","aggregation"],"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"}