mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
enhance: add logs for count(*) (#43001)
Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
parent
08fff353af
commit
c381bf3e41
@ -34,6 +34,7 @@ import (
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
||||
@ -3884,6 +3885,11 @@ func (node *Proxy) Query(ctx context.Context, request *milvuspb.QueryRequest) (*
|
||||
})
|
||||
SetReportValue(res.Status, v)
|
||||
metrics.ProxyReportValue.WithLabelValues(nodeID, hookutil.OpTypeQuery, request.DbName, username).Add(float64(v))
|
||||
|
||||
if log.Ctx(ctx).Core().Enabled(zap.DebugLevel) && matchCountRule(request.GetOutputFields()) {
|
||||
r, _ := protojson.Marshal(res)
|
||||
log.Ctx(ctx).Debug("Count result", zap.String("result", string(r)))
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path"
|
||||
"slices"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@ -665,6 +666,23 @@ func (sd *shardDelegator) Query(ctx context.Context, req *querypb.QueryRequest)
|
||||
}
|
||||
|
||||
log.Debug("Delegator Query done")
|
||||
if log.Core().Enabled(zap.DebugLevel) {
|
||||
sealedIDs := lo.FlatMap(sealed, func(item SnapshotItem, _ int) []int64 {
|
||||
return lo.Map(item.Segments, func(segment SegmentEntry, _ int) int64 {
|
||||
return segment.SegmentID
|
||||
})
|
||||
})
|
||||
slices.Sort(sealedIDs)
|
||||
growingIDs := lo.Map(growing, func(item SegmentEntry, _ int) int64 {
|
||||
return item.SegmentID
|
||||
})
|
||||
slices.Sort(growingIDs)
|
||||
log.Debug("execute count on segments...",
|
||||
zap.Int64s("sealedIDs", sealedIDs),
|
||||
zap.Int64s("growingIDs", growingIDs),
|
||||
zap.Int64("targetVersion", sd.distribution.queryView.version),
|
||||
)
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
@ -67,6 +67,25 @@ func retrieveOnSegments(ctx context.Context, mgr *Manager, segments []Segment, s
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log := log.Ctx(ctx)
|
||||
if log.Core().Enabled(zap.DebugLevel) && req.GetReq().GetIsCount() {
|
||||
allRetrieveCount := result.AllRetrieveCount
|
||||
countRet := result.GetFieldsData()[0].GetScalars().GetLongData().GetData()[0]
|
||||
if allRetrieveCount != countRet {
|
||||
log.Debug("count segment done with delete",
|
||||
zap.String("channel", s.LoadInfo().GetInsertChannel()),
|
||||
zap.Int64("segmentID", s.ID()),
|
||||
zap.Int64("allRetrieveCount", allRetrieveCount),
|
||||
zap.Int64("countRet", countRet))
|
||||
} else {
|
||||
log.Debug("count segment done",
|
||||
zap.String("channel", s.LoadInfo().GetInsertChannel()),
|
||||
zap.Int64("segmentID", s.ID()),
|
||||
zap.Int64("allRetrieveCount", allRetrieveCount),
|
||||
zap.Int64("countRet", countRet))
|
||||
}
|
||||
}
|
||||
resultCh <- RetrieveSegmentResult{
|
||||
result,
|
||||
s,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user