Skip to content

Commit 1e90577

Browse files
authored
executor: fix mppIterator memory leak when got error (#52410) (#53105)
close #52406
1 parent eab1370 commit 1e90577

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/store/copr/mpp.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,23 @@ func (c *MPPClient) EstablishMPPConns(param kv.EstablishMPPConnsParam) (*tikvrpc
255255
// We don't need to process any special error. When we meet errors, just let it fail.
256256
rpcResp, err := c.store.GetTiKVClient().SendRequest(param.Ctx, req.Meta.GetAddress(), wrappedReq, TiFlashReadTimeoutUltraLong)
257257

258+
var stream *tikvrpc.MPPStreamResponse
259+
if rpcResp != nil && rpcResp.Resp != nil {
260+
stream = rpcResp.Resp.(*tikvrpc.MPPStreamResponse)
261+
}
262+
258263
if err != nil {
264+
if stream != nil {
265+
stream.Close()
266+
}
259267
logutil.BgLogger().Warn("establish mpp connection meet error and cannot retry", zap.String("error", err.Error()), zap.Uint64("timestamp", taskMeta.StartTs), zap.Int64("task", taskMeta.TaskId), zap.Int64("mpp-version", taskMeta.MppVersion))
260268
if config.GetGlobalConfig().DisaggregatedTiFlash && !config.GetGlobalConfig().UseAutoScaler {
261269
c.store.GetRegionCache().InvalidateTiFlashComputeStores()
262270
}
263271
return nil, err
264272
}
265273

266-
streamResponse := rpcResp.Resp.(*tikvrpc.MPPStreamResponse)
267-
return streamResponse, nil
274+
return stream, nil
268275
}
269276

270277
// CheckVisibility checks if it is safe to read using given ts.

0 commit comments

Comments
 (0)