{"record":{"id":"cc1057c8ac883cb4","repo":"databendlabs/databend","slug":"node-id-has-to-be-one-of-cluster-member","errorCode":null,"errorMessage":"node id ({}) has to be one of cluster member({:?})","messagePattern":"node id \\((.+?)\\) has to be one of cluster member\\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/import.rs","lineNumber":186,"sourceCode":"            _ => {\n                return Err(anyhow::anyhow!(\"invalid peer raft addr: {}\", addrs[0]));\n            }\n        };\n\n        let node = Node::new(id, endpoint.clone());\n        eprintln!(\"new cluster node:{}\", node);\n\n        nodes.insert(id, node);\n    }\n\n    if nodes.is_empty() {\n        return Ok(nodes);\n    }\n\n    eprintln!(\"new cluster: {:?}\", nodes);\n\n    if !nodes.contains_key(&id) {\n        return Err(anyhow::anyhow!(\n            \"node id ({}) has to be one of cluster member({:?})\",\n            id,\n            nodes.keys().collect::<Vec<_>>()\n        ));\n    }\n\n    Ok(nodes)\n}\n\n// initial_cluster format: node_id=endpoint,grpc_api_addr;\nasync fn init_new_cluster<SP: SpawnApi>(\n    args: &ImportArgs,\n    nodes: BTreeMap<NodeId, Node>,\n    max_log_id: Option<LogId>,\n) -> anyhow::Result<()> {\n    eprintln!();\n    eprintln!(\"Initialize Cluster with: {:?}\", nodes);\n","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/import.rs#L168-L204","documentation":"After building the cluster nodes for a metasrv import, metactl verifies that the node id being imported (from --id) is present among the constructed cluster member node ids. If the id is not a key in the nodes map, the import is aborted because the restored data would not correspond to any known raft member.","triggerScenarios":"Running `metactl --db --import` with an --id value that does not match any node id in the --raft-addr/--peers list; e.g. importing a snapshot with node id 1 into a cluster whose declared node id is 2.","commonSituations":"Cluster reconfiguration after node replacement, reusing an old import command after cluster ids changed, or mixing up node-id with cluster-id.","solutions":["Set --id to one of the cluster member ids listed in the error message (the keys of the nodes map)","Update the peer/address list so it includes an entry for the node id you are importing","If the cluster changed, regenerate the nodes configuration for the new topology before importing","Double-check whether you intended to import into a 'new cluster' (which skips this check) versus the existing cluster"],"exampleFix":"// before\nmetactl --db --import --id 1 --raft-addr '2,node-2:9191'\n// after\nmetactl --db --import --id 2 --raft-addr '2,node-2:9191'","handlingStrategy":"validation","validationCode":"// before import, confirm the --id is present in the cluster member list\nconst node_ids: Vec<u64> = parse_peer_ids(cluster_peers); // e.g. ['2,node-2:9191'] -> [2]\nif !node_ids.contains(&import_id) {\n    panic!(\"--id {} must be one of cluster members {:?}\", import_id, node_ids);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep node id and peer list in a single source of truth","After cluster topology changes, regenerate import scripts","Distinguish node id from cluster id in your runbooks","Dry-run the import command and read the printed 'new cluster: {:?}' line to confirm ids"],"tags":["config","raft","metactl","id-mismatch"],"backgroundTag":"invalid-argument-value","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"}