From 787ce7c121c506edc49bb0442c1816a84aecbc72 Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 3 Feb 2023 14:23:56 +0800 Subject: [PATCH] Add Rated group for checkpoint gc skip case (#21949) Signed-off-by: Congqi Xia --- internal/datacoord/garbage_collector.go | 3 ++- internal/log/global.go | 6 ++++-- internal/querynode/shard_cluster.go | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/datacoord/garbage_collector.go b/internal/datacoord/garbage_collector.go index bcfaeee769..f88072bc77 100644 --- a/internal/datacoord/garbage_collector.go +++ b/internal/datacoord/garbage_collector.go @@ -234,12 +234,13 @@ func (gc *garbageCollector) clearEtcd() { } for _, segment := range drops { + log := log.With(zap.Int64("segmentID", segment.ID)) if !gc.isExpire(segment.GetDroppedAt()) { continue } // segment gc shall only happen when channel cp is after segment dml cp. if segment.GetDmlPosition().GetTimestamp() > channelCPs[segment.GetInsertChannel()] { - log.RatedInfo(60, "dropped segment dml position after channel cp, skip meta gc", + log.WithRateGroup("GC_FAIL_CP_BEFORE", 1, 60).RatedInfo(60, "dropped segment dml position after channel cp, skip meta gc", zap.Uint64("dmlPosTs", segment.GetDmlPosition().GetTimestamp()), zap.Uint64("channelCpTs", channelCPs[segment.GetInsertChannel()]), ) diff --git a/internal/log/global.go b/internal/log/global.go index f9e7580c05..8fc1df50af 100644 --- a/internal/log/global.go +++ b/internal/log/global.go @@ -102,8 +102,10 @@ func RatedWarn(cost float64, msg string, fields ...zap.Field) bool { // With creates a child logger and adds structured context to it. // Fields added to the child don't affect the parent, and vice versa. -func With(fields ...zap.Field) *zap.Logger { - return L().With(fields...).WithOptions(zap.AddCallerSkip(-1)) +func With(fields ...zap.Field) *MLogger { + return &MLogger{ + Logger: L().With(fields...).WithOptions(zap.AddCallerSkip(-1)), + } } // SetLevel alters the logging level. diff --git a/internal/querynode/shard_cluster.go b/internal/querynode/shard_cluster.go index 72aa8a2464..815a2421ed 100644 --- a/internal/querynode/shard_cluster.go +++ b/internal/querynode/shard_cluster.go @@ -202,10 +202,12 @@ func (sc *ShardCluster) Close() { }) } -func (sc *ShardCluster) getLogger() *zap.Logger { - return log.With(zap.Int64("collectionID", sc.collectionID), +func (sc *ShardCluster) getLogger() *log.MLogger { + return log.With( + zap.Int64("collectionID", sc.collectionID), zap.String("channel", sc.vchannelName), - zap.Int64("replicaID", sc.replicaID)) + zap.Int64("replicaID", sc.replicaID), + ) } // serviceable returns whether shard cluster could provide query service.