diff --git a/domain/infosync/info.go b/domain/infosync/info.go index ac9c9f76d4a2f..3d734574accfa 100644 --- a/domain/infosync/info.go +++ b/domain/infosync/info.go @@ -334,6 +334,7 @@ func doRequest(ctx context.Context, addrs []string, route, method string, body i } }) if err == nil { + defer terror.Call(res.Body.Close) bodyBytes, err := io.ReadAll(res.Body) if err != nil { return nil, err @@ -345,7 +346,6 @@ func doRequest(ctx context.Context, addrs []string, route, method string, body i bodyBytes = nil } } - terror.Log(res.Body.Close()) return bodyBytes, err } } @@ -695,6 +695,7 @@ func (is *InfoSyncer) getPrometheusAddr() (string, error) { if err != nil { return "", err } + defer terror.Call(resp.Body.Close) var metricStorage metricStorage dec := json.NewDecoder(resp.Body) err = dec.Decode(&metricStorage) diff --git a/executor/infoschema_reader.go b/executor/infoschema_reader.go index d29d523249d70..0ad44e959465f 100644 --- a/executor/infoschema_reader.go +++ b/executor/infoschema_reader.go @@ -2607,11 +2607,13 @@ func (e *TiFlashSystemTableRetriever) initialize(sctx sessionctx.Context, tiflas if err != nil { return errors.Trace(err) } - _, err = util.InternalHTTPClient().Do(req) + var tmp *http.Response + tmp, err = util.InternalHTTPClient().Do(req) if err != nil { sctx.GetSessionVars().StmtCtx.AppendWarning(err) continue } + defer terror.Call(tmp.Body.Close) e.instanceInfos = append(e.instanceInfos, tiflashInstanceInfo{ id: id, url: url,