Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
e5e4b249
M
milvus
项目概览
milvus
/
milvus
9 个月 前同步成功
通知
260
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
e5e4b249
编写于
9月 14, 2021
作者:
Z
zhenshan.cao
提交者:
GitHub
9月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug: describe collection return wrong shard number (#7841)
Signed-off-by:
N
zhenshan.cao
<
zhenshan.cao@zilliz.com
>
上级
a275992e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
144 addition
and
20 deletion
+144
-20
internal/common/common.go
internal/common/common.go
+1
-0
internal/proxy/rootcoord_mock_test.go
internal/proxy/rootcoord_mock_test.go
+5
-1
internal/proxy/task.go
internal/proxy/task.go
+1
-1
internal/proxy/task_test.go
internal/proxy/task_test.go
+127
-6
internal/querycoord/mock_3rd_component_test.go
internal/querycoord/mock_3rd_component_test.go
+2
-2
internal/rootcoord/root_coord.go
internal/rootcoord/root_coord.go
+0
-2
internal/rootcoord/root_coord_test.go
internal/rootcoord/root_coord_test.go
+5
-5
internal/rootcoord/task.go
internal/rootcoord/task.go
+3
-3
未找到文件。
internal/common/common.go
浏览文件 @
e5e4b249
...
...
@@ -24,4 +24,5 @@ const (
TimeStampField
=
1
RowIDFieldName
=
"RowID"
TimeStampFieldName
=
"Timestamp"
DefaultShardsNum
=
int32
(
2
)
)
internal/proxy/rootcoord_mock_test.go
浏览文件 @
e5e4b249
...
...
@@ -225,7 +225,7 @@ func (coord *RootCoordMock) CreateCollection(ctx context.Context, req *milvuspb.
var
shardsNum
int32
if
req
.
ShardsNum
<=
0
{
shardsNum
=
2
shardsNum
=
common
.
DefaultShardsNum
}
else
{
shardsNum
=
req
.
ShardsNum
}
...
...
@@ -364,6 +364,9 @@ func (coord *RootCoordMock) DescribeCollection(ctx context.Context, req *milvusp
}
meta
:=
coord
.
collID2Meta
[
collID
]
if
meta
.
shardsNum
==
0
{
meta
.
shardsNum
=
int32
(
len
(
meta
.
virtualChannelNames
))
}
return
&
milvuspb
.
DescribeCollectionResponse
{
Status
:
&
commonpb
.
Status
{
...
...
@@ -372,6 +375,7 @@ func (coord *RootCoordMock) DescribeCollection(ctx context.Context, req *milvusp
},
Schema
:
meta
.
schema
,
CollectionID
:
collID
,
ShardsNum
:
meta
.
shardsNum
,
VirtualChannelNames
:
meta
.
virtualChannelNames
,
PhysicalChannelNames
:
meta
.
physicalChannelNames
,
CreatedTimestamp
:
meta
.
createdUtcTimestamp
,
...
...
internal/proxy/task.go
浏览文件 @
e5e4b249
...
...
@@ -2701,7 +2701,7 @@ func (dct *describeCollectionTask) Execute(ctx context.Context) error {
dct
.
result
.
PhysicalChannelNames
=
result
.
PhysicalChannelNames
dct
.
result
.
CreatedTimestamp
=
result
.
CreatedTimestamp
dct
.
result
.
CreatedUtcTimestamp
=
result
.
CreatedUtcTimestamp
dct
.
result
.
ShardsNum
=
result
.
ShardsNum
for
_
,
field
:=
range
result
.
Schema
.
Fields
{
if
field
.
FieldID
>=
common
.
StartOfUserFieldID
{
dct
.
result
.
Schema
.
Fields
=
append
(
dct
.
result
.
Schema
.
Fields
,
&
schemapb
.
FieldSchema
{
...
...
internal/proxy/task_test.go
浏览文件 @
e5e4b249
...
...
@@ -13,18 +13,16 @@ import (
"testing"
"time"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/msgstream"
"github.com/milvus-io/milvus/internal/util/distance"
"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus/internal/common"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/msgstream"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/proto/milvuspb"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/proto/schemapb"
"github.com/milvus-io/milvus/internal/util/distance"
"github.com/milvus-io/milvus/internal/util/funcutil"
"github.com/milvus-io/milvus/internal/util/uniquegenerator"
"github.com/stretchr/testify/assert"
...
...
@@ -1212,6 +1210,129 @@ func TestDescribeCollectionTask(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
task
.
result
.
Status
.
ErrorCode
)
}
func
TestDescribeCollectionTask_ShardsNum1
(
t
*
testing
.
T
)
{
Params
.
Init
()
rc
:=
NewRootCoordMock
()
rc
.
Start
()
defer
rc
.
Stop
()
ctx
:=
context
.
Background
()
InitMetaCache
(
rc
)
prefix
:=
"TestDescribeCollectionTask"
dbName
:=
""
collectionName
:=
prefix
+
funcutil
.
GenRandomStr
()
shardsNum
:=
int32
(
2
)
int64Field
:=
"int64"
floatVecField
:=
"fvec"
dim
:=
128
schema
:=
constructCollectionSchema
(
int64Field
,
floatVecField
,
dim
,
collectionName
)
marshaledSchema
,
err
:=
proto
.
Marshal
(
schema
)
assert
.
NoError
(
t
,
err
)
createColReq
:=
&
milvuspb
.
CreateCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_DropCollection
,
MsgID
:
100
,
Timestamp
:
100
,
},
DbName
:
dbName
,
CollectionName
:
collectionName
,
Schema
:
marshaledSchema
,
ShardsNum
:
shardsNum
,
}
rc
.
CreateCollection
(
ctx
,
createColReq
)
globalMetaCache
.
GetCollectionID
(
ctx
,
collectionName
)
//CreateCollection
task
:=
&
describeCollectionTask
{
Condition
:
NewTaskCondition
(
ctx
),
DescribeCollectionRequest
:
&
milvuspb
.
DescribeCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_DescribeCollection
,
MsgID
:
100
,
Timestamp
:
100
,
},
DbName
:
dbName
,
CollectionName
:
collectionName
,
},
ctx
:
ctx
,
rootCoord
:
rc
,
result
:
nil
,
}
err
=
task
.
PreExecute
(
ctx
)
assert
.
Nil
(
t
,
err
)
err
=
task
.
Execute
(
ctx
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
task
.
result
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
shardsNum
,
task
.
result
.
ShardsNum
)
}
func
TestDescribeCollectionTask_ShardsNum2
(
t
*
testing
.
T
)
{
Params
.
Init
()
rc
:=
NewRootCoordMock
()
rc
.
Start
()
defer
rc
.
Stop
()
ctx
:=
context
.
Background
()
InitMetaCache
(
rc
)
prefix
:=
"TestDescribeCollectionTask"
dbName
:=
""
collectionName
:=
prefix
+
funcutil
.
GenRandomStr
()
int64Field
:=
"int64"
floatVecField
:=
"fvec"
dim
:=
128
schema
:=
constructCollectionSchema
(
int64Field
,
floatVecField
,
dim
,
collectionName
)
marshaledSchema
,
err
:=
proto
.
Marshal
(
schema
)
assert
.
NoError
(
t
,
err
)
createColReq
:=
&
milvuspb
.
CreateCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_DropCollection
,
MsgID
:
100
,
Timestamp
:
100
,
},
DbName
:
dbName
,
CollectionName
:
collectionName
,
Schema
:
marshaledSchema
,
}
rc
.
CreateCollection
(
ctx
,
createColReq
)
globalMetaCache
.
GetCollectionID
(
ctx
,
collectionName
)
//CreateCollection
task
:=
&
describeCollectionTask
{
Condition
:
NewTaskCondition
(
ctx
),
DescribeCollectionRequest
:
&
milvuspb
.
DescribeCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_DescribeCollection
,
MsgID
:
100
,
Timestamp
:
100
,
},
DbName
:
dbName
,
CollectionName
:
collectionName
,
},
ctx
:
ctx
,
rootCoord
:
rc
,
result
:
nil
,
}
task
.
PreExecute
(
ctx
)
// missing collectionID in globalMetaCache
err
=
task
.
Execute
(
ctx
)
assert
.
Nil
(
t
,
err
)
err
=
task
.
Execute
(
ctx
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
task
.
result
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
common
.
DefaultShardsNum
,
task
.
result
.
ShardsNum
)
rc
.
Stop
()
}
func
TestCreatePartitionTask
(
t
*
testing
.
T
)
{
Params
.
Init
()
rc
:=
NewRootCoordMock
()
...
...
internal/querycoord/mock_3rd_component_test.go
浏览文件 @
e5e4b249
...
...
@@ -20,6 +20,7 @@ import (
"strconv"
"sync"
"github.com/milvus-io/milvus/internal/common"
"github.com/milvus-io/milvus/internal/kv"
minioKV
"github.com/milvus-io/milvus/internal/kv/minio"
"github.com/milvus-io/milvus/internal/log"
...
...
@@ -40,7 +41,6 @@ const (
defaultCollectionID
=
UniqueID
(
2021
)
defaultPartitionID
=
UniqueID
(
2021
)
defaultSegmentID
=
UniqueID
(
2021
)
defaultShardsNum
=
2
)
func
genCollectionSchema
(
collectionID
UniqueID
,
isBinary
bool
)
*
schemapb
.
CollectionSchema
{
...
...
@@ -330,7 +330,7 @@ func (data *dataCoordMock) GetRecoveryInfo(ctx context.Context, req *datapb.GetR
channelInfos
:=
make
([]
*
datapb
.
VchannelInfo
,
0
)
data
.
collections
=
append
(
data
.
collections
,
collectionID
)
collectionName
:=
funcutil
.
RandomString
(
8
)
for
i
:=
0
;
i
<
d
efaultShardsNum
;
i
++
{
for
i
:=
int32
(
0
);
i
<
common
.
D
efaultShardsNum
;
i
++
{
vChannel
:=
fmt
.
Sprintf
(
"%s_%d_%d_v"
,
collectionName
,
collectionID
,
i
)
channelInfo
:=
&
datapb
.
VchannelInfo
{
CollectionID
:
collectionID
,
...
...
internal/rootcoord/root_coord.go
浏览文件 @
e5e4b249
...
...
@@ -65,8 +65,6 @@ const (
// MetricRequestsSuccess used to count the num of successful requests
MetricRequestsSuccess
=
"success"
DefaultShardsNum
=
int32
(
2
)
)
func
metricProxy
(
v
int64
)
string
{
...
...
internal/rootcoord/root_coord_test.go
浏览文件 @
e5e4b249
...
...
@@ -22,13 +22,13 @@ import (
"testing"
"time"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus/internal/common"
etcdkv
"github.com/milvus-io/milvus/internal/kv/etcd"
"github.com/milvus-io/milvus/internal/msgstream"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/milvus-io/milvus/internal/proto/etcdpb"
"github.com/milvus-io/milvus/internal/proto/indexpb"
...
...
@@ -2043,9 +2043,9 @@ func TestRootCoord2(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
collName
,
rsp
.
Schema
.
Name
)
assert
.
Equal
(
t
,
collMeta
.
ID
,
rsp
.
CollectionID
)
assert
.
Equal
(
t
,
DefaultShardsNum
,
int32
(
len
(
rsp
.
VirtualChannelNames
)))
assert
.
Equal
(
t
,
DefaultShardsNum
,
int32
(
len
(
rsp
.
PhysicalChannelNames
)))
assert
.
Equal
(
t
,
DefaultShardsNum
,
rsp
.
ShardsNum
)
assert
.
Equal
(
t
,
common
.
DefaultShardsNum
,
int32
(
len
(
rsp
.
VirtualChannelNames
)))
assert
.
Equal
(
t
,
common
.
DefaultShardsNum
,
int32
(
len
(
rsp
.
PhysicalChannelNames
)))
assert
.
Equal
(
t
,
common
.
DefaultShardsNum
,
rsp
.
ShardsNum
)
})
err
=
core
.
Stop
()
assert
.
Nil
(
t
,
err
)
...
...
internal/rootcoord/task.go
浏览文件 @
e5e4b249
...
...
@@ -16,8 +16,7 @@ import (
"fmt"
"github.com/golang/protobuf/proto"
"go.uber.org/zap"
"github.com/milvus-io/milvus/internal/common"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/etcdpb"
...
...
@@ -27,6 +26,7 @@ import (
"github.com/milvus-io/milvus/internal/proto/schemapb"
"github.com/milvus-io/milvus/internal/util/tsoutil"
"github.com/milvus-io/milvus/internal/util/typeutil"
"go.uber.org/zap"
)
type
reqTask
interface
{
...
...
@@ -92,7 +92,7 @@ func (t *CreateCollectionReqTask) Execute(ctx context.Context) error {
return
fmt
.
Errorf
(
"collection name = %s, schema.Name=%s"
,
t
.
Req
.
CollectionName
,
schema
.
Name
)
}
if
t
.
Req
.
ShardsNum
<=
0
{
t
.
Req
.
ShardsNum
=
DefaultShardsNum
t
.
Req
.
ShardsNum
=
common
.
DefaultShardsNum
}
log
.
Debug
(
"CreateCollectionReqTask Execute"
,
zap
.
Any
(
"CollectionName"
,
t
.
Req
.
CollectionName
),
zap
.
Any
(
"ShardsNum"
,
t
.
Req
.
ShardsNum
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录