From 1aada7ade0adfd9f18d993c28dded7470c5e9ad6 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Tue, 9 Jul 2024 18:49:47 +0800 Subject: [PATCH 1/2] This is an automated cherry-pick of #54523 Signed-off-by: ti-chi-bot --- executor/cte.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/executor/cte.go b/executor/cte.go index e0f3ca8664cc2..74ebf0f434f67 100644 --- a/executor/cte.go +++ b/executor/cte.go @@ -439,10 +439,15 @@ func (p *cteProducer) computeRecursivePart(ctx context.Context) (err error) { iterNum++ failpoint.Inject("assertIterTableSpillToDisk", func(maxIter failpoint.Value) { if iterNum > 0 && iterNum < uint64(maxIter.(int)) && err == nil { +<<<<<<< HEAD:executor/cte.go if p.iterInTbl.GetMemBytes() != 0 || p.iterInTbl.GetDiskBytes() == 0 || p.iterOutTbl.GetMemBytes() != 0 || p.iterOutTbl.GetDiskBytes() == 0 || p.resTbl.GetMemBytes() != 0 || p.resTbl.GetDiskBytes() == 0 { p.logTbls(ctx, err, iterNum) +======= + if p.iterInTbl.GetDiskBytes() == 0 && p.iterOutTbl.GetDiskBytes() == 0 && p.resTbl.GetDiskBytes() == 0 { + p.logTbls(ctx, err, iterNum, zapcore.InfoLevel) +>>>>>>> 887637bc3b1 (executor: fix cte mem tracker failpoint condition again (#54523)):pkg/executor/cte.go panic("assert row container spill disk failed") } } From 9eac6912ca7529a9f40a09d222e444679c4b61ee Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Fri, 19 Jul 2024 14:43:29 +0800 Subject: [PATCH 2/2] fix conflict Signed-off-by: guo-shaoge --- executor/cte.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/executor/cte.go b/executor/cte.go index 74ebf0f434f67..8d9c38259c361 100644 --- a/executor/cte.go +++ b/executor/cte.go @@ -31,6 +31,7 @@ import ( "github.com/pingcap/tidb/util/logutil" "github.com/pingcap/tidb/util/memory" "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) var _ Executor = &CTEExec{} @@ -434,20 +435,13 @@ func (p *cteProducer) computeRecursivePart(ctx context.Context) (err error) { if chk.NumRows() == 0 { if iterNum%1000 == 0 { // To avoid too many logs. - p.logTbls(ctx, err, iterNum) + p.logTbls(ctx, err, iterNum, zapcore.DebugLevel) } iterNum++ failpoint.Inject("assertIterTableSpillToDisk", func(maxIter failpoint.Value) { if iterNum > 0 && iterNum < uint64(maxIter.(int)) && err == nil { -<<<<<<< HEAD:executor/cte.go - if p.iterInTbl.GetMemBytes() != 0 || p.iterInTbl.GetDiskBytes() == 0 || - p.iterOutTbl.GetMemBytes() != 0 || p.iterOutTbl.GetDiskBytes() == 0 || - p.resTbl.GetMemBytes() != 0 || p.resTbl.GetDiskBytes() == 0 { - p.logTbls(ctx, err, iterNum) -======= if p.iterInTbl.GetDiskBytes() == 0 && p.iterOutTbl.GetDiskBytes() == 0 && p.resTbl.GetDiskBytes() == 0 { p.logTbls(ctx, err, iterNum, zapcore.InfoLevel) ->>>>>>> 887637bc3b1 (executor: fix cte mem tracker failpoint condition again (#54523)):pkg/executor/cte.go panic("assert row container spill disk failed") } } @@ -766,8 +760,8 @@ func (p *cteProducer) checkAndUpdateCorColHashCode() bool { return changed } -func (p *cteProducer) logTbls(ctx context.Context, err error, iterNum uint64) { - logutil.Logger(ctx).Debug("cte iteration info", +func (p *cteProducer) logTbls(ctx context.Context, err error, iterNum uint64, lvl zapcore.Level) { + logutil.Logger(ctx).Log(lvl, "cte iteration info", zap.Any("iterInTbl mem usage", p.iterInTbl.GetMemBytes()), zap.Any("iterInTbl disk usage", p.iterInTbl.GetDiskBytes()), zap.Any("iterOutTbl mem usage", p.iterOutTbl.GetMemBytes()), zap.Any("iterOutTbl disk usage", p.iterOutTbl.GetDiskBytes()), zap.Any("resTbl mem usage", p.resTbl.GetMemBytes()), zap.Any("resTbl disk usage", p.resTbl.GetDiskBytes()),