From 595b3365af26effc94ad2f0dae1d7e86245c2f1f Mon Sep 17 00:00:00 2001 From: jiyfhust Date: Wed, 20 Mar 2024 17:33:24 +0800 Subject: [PATCH] fix --- pkg/distsql/select_result.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/distsql/select_result.go b/pkg/distsql/select_result.go index 82a6bec7135c8..16a2dd30bd200 100644 --- a/pkg/distsql/select_result.go +++ b/pkg/distsql/select_result.go @@ -603,15 +603,6 @@ func (r *selectResult) Close() error { if respSize > 0 { r.memConsume(-respSize) } - if r.ctx != nil { - if unconsumed, ok := r.resp.(copr.HasUnconsumedCopRuntimeStats); ok && unconsumed != nil { - unconsumedCopStats := unconsumed.CollectUnconsumedCopRuntimeStats() - for _, copStats := range unconsumedCopStats { - _ = r.updateCopRuntimeStats(context.Background(), copStats, time.Duration(0)) - r.ctx.GetSessionVars().StmtCtx.MergeExecDetails(&copStats.ExecDetails, nil) - } - } - } if r.stats != nil { defer func() { if ci, ok := r.resp.(copr.CopInfo); ok { @@ -623,6 +614,13 @@ func (r *selectResult) Close() error { } r.ctx.GetSessionVars().StmtCtx.RuntimeStatsColl.RegisterStats(r.rootPlanID, r.stats) }() + if unconsumed, ok := r.resp.(copr.HasUnconsumedCopRuntimeStats); ok && unconsumed != nil { + unconsumedCopStats := unconsumed.CollectUnconsumedCopRuntimeStats() + for _, copStats := range unconsumedCopStats { + _ = r.updateCopRuntimeStats(context.Background(), copStats, time.Duration(0)) + r.ctx.GetSessionVars().StmtCtx.MergeExecDetails(&copStats.ExecDetails, nil) + } + } } return r.resp.Close() }