Refine the log of CreateCollection (#12385)

Signed-off-by: dragondriver <jiquan.long@zilliz.com>
This commit is contained in:
dragondriver 2021-11-30 20:05:40 +08:00 committed by GitHub
parent 36ef91f412
commit 4056b414f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,6 +143,11 @@ func (node *Proxy) CreateCollection(ctx context.Context, request *milvuspb.Creat
if !node.checkHealthy() { if !node.checkHealthy() {
return unhealthyStatus(), nil return unhealthyStatus(), nil
} }
sp, ctx := trace.StartSpanFromContextWithOperationName(ctx, "Proxy-CreateCollection")
defer sp.Finish()
traceID, _, _ := trace.InfoFromSpan(sp)
cct := &createCollectionTask{ cct := &createCollectionTask{
ctx: ctx, ctx: ctx,
Condition: NewTaskCondition(ctx), Condition: NewTaskCondition(ctx),
@ -150,44 +155,77 @@ func (node *Proxy) CreateCollection(ctx context.Context, request *milvuspb.Creat
rootCoord: node.rootCoord, rootCoord: node.rootCoord,
} }
log.Debug("CreateCollection enqueue", // avoid data race
lenOfSchema := len(request.Schema)
log.Debug("CreateCollection received",
zap.String("traceID", traceID),
zap.String("role", Params.RoleName), zap.String("role", Params.RoleName),
zap.String("db", request.DbName), zap.String("db", request.DbName),
zap.String("collection", request.CollectionName), zap.String("collection", request.CollectionName),
zap.Any("schema", request.Schema)) zap.Int("len(schema)", lenOfSchema),
zap.Int32("shards_num", request.ShardsNum))
err := node.sched.ddQueue.Enqueue(cct) err := node.sched.ddQueue.Enqueue(cct)
if err != nil { if err != nil {
log.Debug("CreateCollection failed to enqueue",
zap.Error(err),
zap.String("traceID", traceID),
zap.String("role", Params.RoleName),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Int("len(schema)", lenOfSchema),
zap.Int32("shards_num", request.ShardsNum))
return &commonpb.Status{ return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError, ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: err.Error(), Reason: err.Error(),
}, nil }, nil
} }
log.Debug("CreateCollection", log.Debug("CreateCollection enqueued",
zap.String("traceID", traceID),
zap.String("role", Params.RoleName), zap.String("role", Params.RoleName),
zap.Int64("msgID", request.Base.MsgID), zap.Int64("MsgID", cct.ID()),
zap.Uint64("BeginTs", cct.BeginTs()),
zap.Uint64("EndTs", cct.EndTs()),
zap.Uint64("timestamp", request.Base.Timestamp), zap.Uint64("timestamp", request.Base.Timestamp),
zap.String("db", request.DbName), zap.String("db", request.DbName),
zap.String("collection", request.CollectionName)) zap.String("collection", request.CollectionName),
defer func() { zap.Int("len(schema)", lenOfSchema),
log.Debug("CreateCollection Done", zap.Int32("shards_num", request.ShardsNum))
zap.Error(err),
zap.String("role", Params.RoleName),
zap.Int64("msgID", request.Base.MsgID),
zap.Uint64("timestamp", request.Base.Timestamp),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
)
}()
err = cct.WaitToFinish() err = cct.WaitToFinish()
if err != nil { if err != nil {
log.Debug("CreateCollection failed to WaitToFinish",
zap.Error(err),
zap.String("traceID", traceID),
zap.String("role", Params.RoleName),
zap.Int64("MsgID", cct.ID()),
zap.Uint64("BeginTs", cct.BeginTs()),
zap.Uint64("EndTs", cct.EndTs()),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Int("len(schema)", lenOfSchema),
zap.Int32("shards_num", request.ShardsNum))
return &commonpb.Status{ return &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError, ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: err.Error(), Reason: err.Error(),
}, nil }, nil
} }
log.Debug("CreateCollection done",
zap.String("traceID", traceID),
zap.String("role", Params.RoleName),
zap.Int64("MsgID", cct.ID()),
zap.Uint64("BeginTs", cct.BeginTs()),
zap.Uint64("EndTs", cct.EndTs()),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName),
zap.Int("len(schema)", lenOfSchema),
zap.Int32("shards_num", request.ShardsNum))
return cct.result, nil return cct.result, nil
} }