mirror of https://github.com/milvus-io/milvus.git
enhance: [2.5] run analyzer should get database name from grpc context (#42399)
pr:https://github.com/milvus-io/milvus/pull/42398 --------- Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>pull/42425/head
parent
99c6209ffc
commit
d9706150d2
|
|
@ -275,6 +275,11 @@ func fillDatabase(ctx context.Context, req interface{}) (context.Context, interf
|
|||
r.DbName = GetCurDBNameFromContextOrDefault(ctx)
|
||||
}
|
||||
return ctx, r
|
||||
case *milvuspb.RunAnalyzerRequest:
|
||||
if r.DbName == "" {
|
||||
r.DbName = GetCurDBNameFromContextOrDefault(ctx)
|
||||
}
|
||||
return ctx, r
|
||||
default:
|
||||
}
|
||||
return ctx, req
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ func TestDatabaseInterceptor(t *testing.T) {
|
|||
&milvuspb.OperatePrivilegeRequest{Entity: &milvuspb.GrantEntity{}},
|
||||
&milvuspb.SelectGrantRequest{Entity: &milvuspb.GrantEntity{}},
|
||||
&milvuspb.ManualCompactionRequest{},
|
||||
&milvuspb.RunAnalyzerRequest{},
|
||||
}
|
||||
|
||||
md := metadata.Pairs(util.HeaderDBName, "db")
|
||||
|
|
|
|||
|
|
@ -2248,8 +2248,8 @@ func TestRunAnalyzer(t *testing.T) {
|
|||
|
||||
fieldMap := &typeutil.ConcurrentMap[string, int64]{}
|
||||
fieldMap.Insert("test_text", 100)
|
||||
mockCache.EXPECT().GetCollectionID(mock.Anything, "default", "test_collection").Return(1, nil)
|
||||
mockCache.EXPECT().GetCollectionSchema(mock.Anything, "default", "test_collection").Return(&schemaInfo{
|
||||
mockCache.EXPECT().GetCollectionID(mock.Anything, mock.Anything, "test_collection").Return(1, nil)
|
||||
mockCache.EXPECT().GetCollectionSchema(mock.Anything, mock.Anything, "test_collection").Return(&schemaInfo{
|
||||
CollectionSchema: &schemapb.CollectionSchema{
|
||||
Fields: []*schemapb.FieldSchema{{
|
||||
FieldID: 100,
|
||||
|
|
|
|||
|
|
@ -2858,20 +2858,16 @@ func (t *RunAnalyzerTask) OnEnqueue() error {
|
|||
}
|
||||
|
||||
func (t *RunAnalyzerTask) PreExecute(ctx context.Context) error {
|
||||
dbName := t.GetDbName()
|
||||
if dbName == "" {
|
||||
dbName = "default"
|
||||
}
|
||||
t.dbName = dbName
|
||||
t.dbName = t.GetDbName()
|
||||
|
||||
collID, err := globalMetaCache.GetCollectionID(ctx, dbName, t.GetCollectionName())
|
||||
collID, err := globalMetaCache.GetCollectionID(ctx, t.dbName, t.GetCollectionName())
|
||||
if err != nil { // err is not nil if collection not exists
|
||||
return merr.WrapErrAsInputErrorWhen(err, merr.ErrCollectionNotFound, merr.ErrDatabaseNotFound)
|
||||
}
|
||||
|
||||
t.collectionID = collID
|
||||
|
||||
schema, err := globalMetaCache.GetCollectionSchema(ctx, dbName, t.GetCollectionName())
|
||||
schema, err := globalMetaCache.GetCollectionSchema(ctx, t.dbName, t.GetCollectionName())
|
||||
if err != nil { // err is not nil if collection not exists
|
||||
return merr.WrapErrAsInputErrorWhen(err, merr.ErrCollectionNotFound, merr.ErrDatabaseNotFound)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue