diff --git a/executor/coprocessor.go b/executor/coprocessor.go index 8970629c9f4b8..323abe865425e 100644 --- a/executor/coprocessor.go +++ b/executor/coprocessor.go @@ -63,6 +63,7 @@ func (h *CoprocessorDAGHandler) HandleRequest(ctx context.Context, req *coproces chk := newFirstChunk(e) tps := e.base().retFieldTypes var totalChunks, partChunks []tipb.Chunk + memTracker := h.sctx.GetSessionVars().StmtCtx.MemTracker for { chk.Reset() err = Next(ctx, e, chk) @@ -76,6 +77,9 @@ func (h *CoprocessorDAGHandler) HandleRequest(ctx context.Context, req *coproces if err != nil { return h.buildErrorResponse(err) } + for _, ch := range partChunks { + memTracker.Consume(int64(ch.Size())) + } totalChunks = append(totalChunks, partChunks...) } if err := e.Close(); err != nil {