From 54fd72001bca74288d02134809424aeea7d3f19d Mon Sep 17 00:00:00 2001 From: Ping Yu Date: Sun, 2 Jun 2024 22:53:51 +0800 Subject: [PATCH] pd: handle get members with error (#452) --- src/pd/cluster.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pd/cluster.rs b/src/pd/cluster.rs index f723f8f7..8c8f0d7c 100644 --- a/src/pd/cluster.rs +++ b/src/pd/cluster.rs @@ -234,6 +234,19 @@ impl Connection { .get_members(pdpb::GetMembersRequest::default()) .await? .into_inner(); + if let Some(err) = resp + .header + .as_ref() + .and_then(|header| header.error.as_ref()) + { + return Err(internal_err!("failed to get PD members, err {:?}", err)); + } + if resp.leader.is_none() { + return Err(internal_err!( + "unexpected no PD leader in get member resp: {:?}", + resp + )); + } Ok((client, keyspace_client, resp)) }