From 51edb06d042f92786c3ed4fc139a35df8ca480c7 Mon Sep 17 00:00:00 2001 From: husharp Date: Fri, 22 Mar 2024 18:17:28 +0800 Subject: [PATCH 1/2] fix nil Signed-off-by: husharp --- pkg/infoschema/tables.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/infoschema/tables.go b/pkg/infoschema/tables.go index e94f4add54a50..349bcb5d993a6 100644 --- a/pkg/infoschema/tables.go +++ b/pkg/infoschema/tables.go @@ -1989,7 +1989,7 @@ func getMicroServiceServerInfo(ctx sessionctx.Context, serviceName string) ([]Se req.Header.Add("PD-Allow-follower-handle", "true") resp, err := util.InternalHTTPClient().Do(req) // PD is not in the microservice mode - if resp.StatusCode == http.StatusServiceUnavailable { + if resp != nil && resp.StatusCode == http.StatusNotFound { terror.Log(resp.Body.Close()) return servers, nil } From a5e0a292b6574c5f7592add1bf50894c2120b855 Mon Sep 17 00:00:00 2001 From: husharp Date: Fri, 22 Mar 2024 18:39:38 +0800 Subject: [PATCH 2/2] fix nil Signed-off-by: husharp --- pkg/infoschema/tables.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/infoschema/tables.go b/pkg/infoschema/tables.go index 349bcb5d993a6..67b14a05d3c82 100644 --- a/pkg/infoschema/tables.go +++ b/pkg/infoschema/tables.go @@ -1988,8 +1988,7 @@ func getMicroServiceServerInfo(ctx sessionctx.Context, serviceName string) ([]Se } req.Header.Add("PD-Allow-follower-handle", "true") resp, err := util.InternalHTTPClient().Do(req) - // PD is not in the microservice mode - if resp != nil && resp.StatusCode == http.StatusNotFound { + if resp == nil || resp.StatusCode != http.StatusOK { terror.Log(resp.Body.Close()) return servers, nil }