{"record":{"id":"dc13d4fd61db289a","repo":"tikv/tikv","slug":"get-region-info-should-success","errorCode":null,"errorMessage":"get_region_info should success","messagePattern":"get_region_info should success","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/tikv-ctl/src/main.rs","lineNumber":898,"sourceCode":"    let pd = pd.unwrap_or_else(|| {\n        exit_with_clap_error(\n            ErrorKind::MissingRequiredArgument,\n            \"--pd is required for this command\",\n        );\n    });\n    let cfg = PdConfig::new(vec![pd]);\n    cfg.validate().unwrap();\n    RpcClient::new(&cfg, None, mgr).unwrap_or_else(|e| perror_and_exit(\"RpcClient::new\", e))\n}\n\nfn split_region(pd_client: &RpcClient, mgr: Arc<SecurityManager>, region_id: u64, key: Vec<u8>) {\n    let region = block_on(pd_client.get_region_by_id(region_id))\n        .expect(\"get_region_by_id should success\")\n        .expect(\"must have the region\");\n\n    let leader = pd_client\n        .get_region_info(region.get_start_key())\n        .expect(\"get_region_info should success\")\n        .leader\n        .expect(\"region must have leader\");\n\n    let store = pd_client\n        .get_store(leader.get_store_id())\n        .expect(\"get_store should success\");\n\n    let tikv_client = {\n        let cb = ChannelBuilder::new(Arc::new(Environment::new(1)));\n        let channel = mgr.connect(cb, store.get_address());\n        TikvClient::new(channel)\n    };\n\n    let mut req = SplitRegionRequest::default();\n    req.mut_context().set_region_id(region_id);\n    req.mut_context()\n        .set_region_epoch(region.get_region_epoch().clone());\n    req.set_split_key(key);","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/tikv/tikv/blob/78aedc1c81ef3f7d8bacc6e9d09f56460f134937/cmd/tikv-ctl/src/main.rs#L880-L916","documentation":"After locating the region, split_region asks PD for current region info (get_region_info) at the region's start key. If the RPC to PD fails (network error, PD unavailable), expect panics with 'get_region_info should success'.","triggerScenarios":"PD is down or unreachable from tikv-ctl; network partition between the control host and PD; TLS/security manager misconfiguration blocking the gRPC call.","commonSituations":"Running tikv-ctl during PD maintenance or cluster outage; firewall blocking the PD client port; wrong security certificates for a TLS-enabled cluster.","solutions":["Check PD reachability: `curl http://<pd>:2379/pd/api/v1/version` and confirm the --pd address is correct.","Retry the command once PD connectivity is restored; this is a transient infrastructure failure.","If TLS is enabled, pass the correct CA/cert/key args to tikv-ctl so the gRPC channel can be established."],"exampleFix":"// before\nlet leader = pd_client\n    .get_region_info(region.get_start_key())\n    .expect(\"get_region_info should success\")\n    .leader\n    .expect(\"region must have leader\");\n// after\nlet region_info = match block_on(pd_client.get_region_info(region.get_start_key())) {\n    Ok(info) => info,\n    Err(e) => { eprintln!(\"get_region_info failed: {:?}\", e); return; }\n};","handlingStrategy":"retry","validationCode":"// check PD health before running the command\ncurl -fsS http://<pd-host>:2379/pd/api/v1/version || echo \"PD unreachable\"","typeGuard":null,"tryCatchPattern":"// wrap the PD call; this is an io/grpc error, retry transient failures\nmatch pd_client.get_region_info(region.get_start_key()) {\n    Ok(info) => info,\n    Err(e) => { backoff_retry(|| pd_client.get_region_info(...)); return; }\n}","preventionTips":["Confirm PD endpoints and ports are reachable from the control host","Keep CA/cert/key flags consistent with the cluster's TLS config","Avoid running tikv-ctl during PD maintenance windows"],"tags":["tikv-ctl","pd","network","grpc"],"backgroundTag":"pd-unreachable","analyzedSha":"78aedc1c81ef3f7d8bacc6e9d09f56460f134937","analyzedAt":"2026-09-03T23:31:32.398Z","contentChangedAt":"2026-09-03T23:31:32.398Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}