From 70995383bf8060ea6d7a24d5bb32da3ac0a960ef Mon Sep 17 00:00:00 2001 From: yah01 Date: Fri, 10 Nov 2023 14:32:20 +0800 Subject: [PATCH] enhance: modify log to avoid ambiguity and improve readability (#28331) Signed-off-by: yah01 --- internal/querycoordv2/task/scheduler.go | 14 +++++++------- internal/querycoordv2/task/task.go | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/querycoordv2/task/scheduler.go b/internal/querycoordv2/task/scheduler.go index 8baf0150cb..9b23359bf5 100644 --- a/internal/querycoordv2/task/scheduler.go +++ b/internal/querycoordv2/task/scheduler.go @@ -551,10 +551,10 @@ func (scheduler *taskScheduler) schedule(node int64) { // The scheduler doesn't limit the number of tasks, // to commit tasks to executors as soon as possible, to reach higher merge possibility - failCount := atomic.NewInt32(0) + commmittedNum := atomic.NewInt32(0) funcutil.ProcessFuncParallel(len(toProcess), hardware.GetCPUNum(), func(idx int) error { - if !scheduler.process(toProcess[idx]) { - failCount.Inc() + if scheduler.process(toProcess[idx]) { + commmittedNum.Inc() } return nil }, "process") @@ -565,7 +565,7 @@ func (scheduler *taskScheduler) schedule(node int64) { log.Info("processed tasks", zap.Int("toProcessNum", len(toProcess)), - zap.Int32("failCount", failCount.Load()), + zap.Int32("committedNum", commmittedNum.Load()), zap.Int("toRemoveNum", len(toRemove)), ) @@ -689,7 +689,7 @@ func (scheduler *taskScheduler) recordSegmentTaskError(task *SegmentTask) { zap.Int64("collectionID", task.CollectionID()), zap.Int64("replicaID", task.ReplicaID()), zap.Int64("segmentID", task.SegmentID()), - zap.Int32("taskStatus", task.Status()), + zap.String("status", task.Status()), zap.Error(task.err), ) meta.GlobalFailedLoadCache.Put(task.collectionID, task.Err()) @@ -700,7 +700,7 @@ func (scheduler *taskScheduler) remove(task Task) { zap.Int64("taskID", task.ID()), zap.Int64("collectionID", task.CollectionID()), zap.Int64("replicaID", task.ReplicaID()), - zap.Int32("taskStatus", task.Status()), + zap.String("status", task.Status()), ) task.Cancel(nil) scheduler.tasks.Remove(task.ID()) @@ -725,7 +725,7 @@ func (scheduler *taskScheduler) remove(task Task) { } scheduler.updateTaskMetrics() - log.Debug("task removed", zap.Stack("stack")) + log.Info("task removed") } func (scheduler *taskScheduler) checkStale(task Task) error { diff --git a/internal/querycoordv2/task/task.go b/internal/querycoordv2/task/task.go index f2d4446337..fd3e7cbcb9 100644 --- a/internal/querycoordv2/task/task.go +++ b/internal/querycoordv2/task/task.go @@ -33,16 +33,16 @@ import ( ) type ( - Status = int32 + Status = string Priority int32 ) const ( - TaskStatusCreated Status = iota + 1 - TaskStatusStarted - TaskStatusSucceeded - TaskStatusCanceled - TaskStatusFailed + TaskStatusCreated = "created" + TaskStatusStarted = "started" + TaskStatusSucceeded = "succeeded" + TaskStatusCanceled = "canceled" + TaskStatusFailed = "failed" ) const ( @@ -107,7 +107,7 @@ type baseTask struct { loadType querypb.LoadType source Source - status *atomic.Int32 + status *atomic.String priority Priority err error actions []Action @@ -128,7 +128,7 @@ func newBaseTask(ctx context.Context, source Source, collectionID, replicaID Uni replicaID: replicaID, shard: shard, - status: atomic.NewInt32(TaskStatusStarted), + status: atomic.NewString(TaskStatusStarted), priority: TaskPriorityNormal, ctx: ctx, cancel: cancel,