From b5e17ad9f517a5bad557d0df985ce1ec7e16cf60 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Tue, 20 Sep 2022 16:21:05 +0800 Subject: [PATCH] store: return right error when to get non-200 http code from pd (#37982) close pingcap/tidb#37983 --- store/helper/helper.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/store/helper/helper.go b/store/helper/helper.go index 471d3d179fbdb..995cf0b5fe675 100644 --- a/store/helper/helper.go +++ b/store/helper/helper.go @@ -1001,7 +1001,13 @@ func (h *Helper) GetPDRegionStats(tableID int64, stats *PDRegionStats, noIndexSt logutil.BgLogger().Error("err", zap.Error(err)) } }() - + if resp.StatusCode != http.StatusOK { + body, err := io.ReadAll(resp.Body) + if err != nil { + return errors.Errorf("GetPDRegionStats %d: %s", resp.StatusCode, err) + } + return errors.Errorf("GetPDRegionStats %d: %s", resp.StatusCode, string(body)) + } dec := json.NewDecoder(resp.Body) return dec.Decode(stats)