{"record":{"id":"9bcbe0fef4920d39","repo":"databendlabs/databend","slug":"unreachable","errorCode":null,"errorMessage":"_ => unreachable!()","messagePattern":"_ => unreachable!\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/pipelines/processors/transforms/aggregator/serde/aggregate_scatter.rs","lineNumber":238,"sourceCode":"                            }\n                        }\n                    }\n\n                    Ok(partitions\n                        .into_iter()\n                        .map(|data| AggregateMeta::Partitioned {\n                            bucket,\n                            data: PartitionedData::Mixed(data),\n                        })\n                        .collect())\n                }\n            },\n            AggregateMeta::AggregatePayload(p) => Ok(self\n                .scatter_payload(p.bucket, p.payload, p.max_partition_count)\n                .into_iter()\n                .map(AggregateMeta::AggregatePayload)\n                .collect()),\n            _ => unreachable!(),\n        }\n    }\n\n    fn scatter_payload(\n        &self,\n        bucket: isize,\n        payload: Payload,\n        max_partition_count: usize,\n    ) -> Vec<AggregatePayload> {\n        payload\n            .scatter_into_buckets(self.buckets)\n            .into_iter()\n            .map(|payload| AggregatePayload {\n                bucket,\n                payload,\n                max_partition_count,\n            })\n            .collect()","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/pipelines/processors/transforms/aggregator/serde/aggregate_scatter.rs#L220-L256","documentation":"`AggregatedScatter::scatter_by_rows` panics on any `AggregateMeta` variant other than Serialized, AggregateFunctionArgument (if handled), or AggregatePayload. Row-based scatter expects only the metadata variants that carry per-partition data it can redistribute; encountering another variant (e.g. BucketSpilled or an empty/legacy variant) breaks the scatter invariant.","triggerScenarios":"Calling `scatter` (which routes to `scatter_by_rows` in row shuffle mode) with an `AggregateMeta` fragment whose variant is not supported by row-based scattering — typically fragments containing spilled-bucket state or unexpected metadata during distributed row-mode aggregation.","commonSituations":"Distributed aggregation with row-based shuffle combined with spilling or mixed partition states; planner/executor combinations that deliver unsupported AggregateMeta variants to the scatter stage.","solutions":["Check whether the failing query uses row-based aggregate shuffle with spilling; try bucket-based shuffle mode or disable spilling to avoid the unsupported variant","Log the offending `AggregateMeta` variant to identify which path produced it","Match the variant explicitly and return an `ErrorCode::Internal` describing it instead of a bare panic","Upgrade Databend — scatter handling for spilled/mixed partitions is an area of active fixes"],"exampleFix":"// before\n_ => unreachable!(),\n// after\nother => Err(ErrorCode::Internal(format!(\n    \"scatter_by_rows does not support AggregateMeta variant: {:?}\", other))),","handlingStrategy":"type-guard","validationCode":"if matches!(meta, AggregateMeta::BucketSpilled(_) | AggregateMeta::Serialized(_)) && scatter_mode == Row { return Err(ErrorCode::Internal(\"unsupported AggregateMeta variant for row scatter\")); }","typeGuard":"fn scatters_by_rows(m: &AggregateMeta) -> bool { matches!(m, AggregateMeta::AggregatePayload(_) | AggregateMeta::Serialized(_)) }","tryCatchPattern":null,"preventionTips":["Enumerate and match every AggregateMeta variant explicitly in scatter code","Avoid combining row-mode scatter with spilling until supported","Add unit tests scattering all AggregateMeta variants in each shuffle mode"],"tags":["rust","panic","aggregation","distributed"],"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"}