{"record":{"id":"a79ef5c12fb13c73","repo":"risingwavelabs/risingwave","slug":"non-duplicate","errorCode":null,"errorMessage":"non duplicate","messagePattern":"non duplicate","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/src/manager/metadata.rs","lineNumber":352,"sourceCode":"            .list_fragment_database_ids(Some(\n                fragment_map\n                    .keys()\n                    .map(|fragment_id| *fragment_id as _)\n                    .collect(),\n            ))\n            .await?\n            .into_iter()\n            .map(|(fragment_id, database_id)| (fragment_id as FragmentId, database_id))\n            .collect();\n        let mut ret: HashMap<_, HashMap<_, _>> = HashMap::new();\n        for (fragment_id, value) in fragment_map {\n            let database_id = *fragment_to_database_map\n                .get(&fragment_id)\n                .ok_or_else(|| anyhow!(\"cannot get database_id of fragment {fragment_id}\"))?;\n            ret.entry(database_id)\n                .or_default()\n                .try_insert(fragment_id, value)\n                .expect(\"non duplicate\");\n        }\n        Ok(ret)\n    }\n\n    pub async fn list_creating_jobs(&self) -> MetaResult<HashSet<JobId>> {\n        Ok(self\n            .catalog_controller\n            .list_creating_jobs(false, None)\n            .await?\n            .into_iter()\n            .map(|(job_id, _, _, _, _)| job_id)\n            .collect())\n    }\n\n    pub async fn list_sources(&self) -> MetaResult<Vec<PbSource>> {\n        self.catalog_controller.list_sources().await\n    }\n","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/meta/src/manager/metadata.rs#L334-L370","documentation":"This is an `.expect(\"non duplicate\")` panic inside `split_fragment_map_by_database`, fired by `HashMap::try_insert` when the same fragment_id appears twice for the same database. The library asserts that the input fragment map has no duplicate fragment ids; duplicates indicate a corrupted or doubly-built map.","triggerScenarios":"Passing a fragment map (or upstream iterator) that contains the same fragment_id more than once — e.g. joining/merging fragment lists from multiple sources that overlap, or a catalog read returning duplicate rows.","commonSituations":"Buggy aggregation of per-table fragment maps; catalog scans with duplicate records after meta-node state restore; tests constructing fixture maps by hand that repeat fragment ids.","solutions":["Deduplicate the fragment map before calling: build it with `collect()` into a HashMap, which silently overwrites, or explicitly reject duplicates upstream.","Check the upstream producer of fragment ids for double-emission (e.g. merged iterators or repeated table scans).","Inspect meta-node catalog storage for duplicate fragment rows and repair them.","If duplicates are expected/benign, replace `try_insert(..).expect(..)` with overwrite semantics."],"exampleFix":"// before\nret.entry(database_id).or_default().try_insert(fragment_id, value).expect(\"non duplicate\");\n// after\nret.entry(database_id).or_default().insert(fragment_id, value); // overwrite duplicates instead of panicking","handlingStrategy":"validation","validationCode":"// reject duplicate fragment ids up front\nlet mut seen = std::collections::HashSet::new();\nfor id in fragment_map.keys() {\n    if !seen.insert(*id) { return Err(anyhow!(\"duplicate fragment id {}\", id)); }\n}","typeGuard":null,"tryCatchPattern":"// this path panics (expect), so it cannot be caught; validate inputs beforehand\nassert_unique_fragment_ids(&fragment_map)?;","preventionTips":["Build fragment maps with HashMap collect (which deduplicates) rather than Vec-based joins","Audit any code that merges fragment lists from multiple sources for overlapping ids","Check catalog storage for duplicate rows after meta-node restores"],"tags":["meta","duplicate-key","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-23T08:17:48.524Z"}