Skip to content

Commit

Permalink
store: return right error when to get non-200 http code from pd (#37982)
Browse files Browse the repository at this point in the history
close #37983
  • Loading branch information
hawkingrei authored Sep 20, 2022
1 parent 3f43ecf commit b5e17ad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion store/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b5e17ad

Please sign in to comment.