Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
d830791e
M
milvus
项目概览
milvus
/
milvus
12 个月 前同步成功
通知
261
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,发现更多精彩内容 >>
未验证
提交
d830791e
编写于
2月 07, 2022
作者:
C
congqixia
提交者:
GitHub
2月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Respect SegmentIDs in querynode.GetSegmentInfo (#15455)
Signed-off-by:
N
Congqi Xia
<
congqi.xia@zilliz.com
>
上级
f1ea9613
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
32 deletion
+36
-32
internal/querynode/impl.go
internal/querynode/impl.go
+25
-7
internal/querynode/impl_test.go
internal/querynode/impl_test.go
+11
-25
未找到文件。
internal/querynode/impl.go
浏览文件 @
d830791e
...
@@ -489,10 +489,14 @@ func (node *QueryNode) GetSegmentInfo(ctx context.Context, in *queryPb.GetSegmen
...
@@ -489,10 +489,14 @@ func (node *QueryNode) GetSegmentInfo(ctx context.Context, in *queryPb.GetSegmen
}
}
return
res
,
nil
return
res
,
nil
}
}
infos
:=
make
([]
*
queryPb
.
SegmentInfo
,
0
)
var
segmentInfos
[]
*
queryPb
.
SegmentInfo
segmentIDs
:=
make
(
map
[
int64
]
struct
{})
for
_
,
segmentID
:=
range
in
.
GetSegmentIDs
()
{
segmentIDs
[
segmentID
]
=
struct
{}{}
}
// get info from historical
// get info from historical
// node.historical.replica.printReplica()
historicalSegmentInfos
,
err
:=
node
.
historical
.
replica
.
getSegmentInfosByColID
(
in
.
CollectionID
)
historicalSegmentInfos
,
err
:=
node
.
historical
.
replica
.
getSegmentInfosByColID
(
in
.
CollectionID
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Debug
(
"GetSegmentInfo: get historical segmentInfo failed"
,
zap
.
Int64
(
"collectionID"
,
in
.
CollectionID
),
zap
.
Error
(
err
))
log
.
Debug
(
"GetSegmentInfo: get historical segmentInfo failed"
,
zap
.
Int64
(
"collectionID"
,
in
.
CollectionID
),
zap
.
Error
(
err
))
...
@@ -504,10 +508,9 @@ func (node *QueryNode) GetSegmentInfo(ctx context.Context, in *queryPb.GetSegmen
...
@@ -504,10 +508,9 @@ func (node *QueryNode) GetSegmentInfo(ctx context.Context, in *queryPb.GetSegmen
}
}
return
res
,
nil
return
res
,
nil
}
}
infos
=
append
(
infos
,
historicalSegmentInfos
...
)
segmentInfos
=
append
(
segmentInfos
,
filterSegmentInfo
(
historicalSegmentInfos
,
segmentIDs
)
...
)
// get info from streaming
// get info from streaming
// node.streaming.replica.printReplica()
streamingSegmentInfos
,
err
:=
node
.
streaming
.
replica
.
getSegmentInfosByColID
(
in
.
CollectionID
)
streamingSegmentInfos
,
err
:=
node
.
streaming
.
replica
.
getSegmentInfosByColID
(
in
.
CollectionID
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Debug
(
"GetSegmentInfo: get streaming segmentInfo failed"
,
zap
.
Int64
(
"collectionID"
,
in
.
CollectionID
),
zap
.
Error
(
err
))
log
.
Debug
(
"GetSegmentInfo: get streaming segmentInfo failed"
,
zap
.
Int64
(
"collectionID"
,
in
.
CollectionID
),
zap
.
Error
(
err
))
...
@@ -519,17 +522,32 @@ func (node *QueryNode) GetSegmentInfo(ctx context.Context, in *queryPb.GetSegmen
...
@@ -519,17 +522,32 @@ func (node *QueryNode) GetSegmentInfo(ctx context.Context, in *queryPb.GetSegmen
}
}
return
res
,
nil
return
res
,
nil
}
}
infos
=
append
(
infos
,
streamingSegmentInfos
...
)
segmentInfos
=
append
(
segmentInfos
,
filterSegmentInfo
(
streamingSegmentInfos
,
segmentIDs
)
...
)
// log.Debug("GetSegmentInfo: get segment info from query node", zap.Int64("nodeID", node.session.ServerID), zap.Any("segment infos", infos))
return
&
queryPb
.
GetSegmentInfoResponse
{
return
&
queryPb
.
GetSegmentInfoResponse
{
Status
:
&
commonpb
.
Status
{
Status
:
&
commonpb
.
Status
{
ErrorCode
:
commonpb
.
ErrorCode_Success
,
ErrorCode
:
commonpb
.
ErrorCode_Success
,
},
},
Infos
:
i
nfos
,
Infos
:
segmentI
nfos
,
},
nil
},
nil
}
}
// filterSegmentInfo returns segment info which segment id in segmentIDs map
func
filterSegmentInfo
(
segmentInfos
[]
*
queryPb
.
SegmentInfo
,
segmentIDs
map
[
int64
]
struct
{})
[]
*
queryPb
.
SegmentInfo
{
if
len
(
segmentIDs
)
==
0
{
return
segmentInfos
}
filtered
:=
make
([]
*
queryPb
.
SegmentInfo
,
0
,
len
(
segmentIDs
))
for
_
,
info
:=
range
segmentInfos
{
_
,
ok
:=
segmentIDs
[
info
.
GetSegmentID
()]
if
!
ok
{
continue
}
filtered
=
append
(
filtered
,
info
)
}
return
filtered
}
// isHealthy checks if QueryNode is healthy
// isHealthy checks if QueryNode is healthy
func
(
node
*
QueryNode
)
isHealthy
()
bool
{
func
(
node
*
QueryNode
)
isHealthy
()
bool
{
code
:=
node
.
stateCode
.
Load
()
.
(
internalpb
.
StateCode
)
code
:=
node
.
stateCode
.
Load
()
.
(
internalpb
.
StateCode
)
...
...
internal/querynode/impl_test.go
浏览文件 @
d830791e
...
@@ -230,10 +230,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -230,10 +230,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
defer
cancel
()
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
t
.
Run
(
"test GetSegmentInfo"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test GetSegmentInfo"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -242,7 +239,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -242,7 +239,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgID
:
rand
.
Int63
(),
MsgID
:
rand
.
Int63
(),
},
},
SegmentIDs
:
[]
UniqueID
{
defaultSegmentID
},
SegmentIDs
:
[]
UniqueID
{},
CollectionID
:
defaultCollectionID
,
CollectionID
:
defaultCollectionID
,
}
}
...
@@ -250,15 +247,19 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -250,15 +247,19 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
req
.
SegmentIDs
=
[]
UniqueID
{
-
1
}
rsp
,
err
=
node
.
GetSegmentInfo
(
ctx
,
req
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
0
,
len
(
rsp
.
GetInfos
()))
node
.
UpdateStateCode
(
internalpb
.
StateCode_Abnormal
)
node
.
UpdateStateCode
(
internalpb
.
StateCode_Abnormal
)
rsp
,
err
=
node
.
GetSegmentInfo
(
ctx
,
req
)
rsp
,
err
=
node
.
GetSegmentInfo
(
ctx
,
req
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test no collection in historical"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test no collection in historical"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -279,9 +280,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -279,9 +280,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test no collection in streaming"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test no collection in streaming"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -302,9 +301,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -302,9 +301,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test different segment type"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test different segment type"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -346,9 +343,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -346,9 +343,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test GetSegmentInfo with indexed segment"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test GetSegmentInfo with indexed segment"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -380,9 +375,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -380,9 +375,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test GetSegmentInfo without streaming partition"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test GetSegmentInfo without streaming partition"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -391,7 +384,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -391,7 +384,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgID
:
rand
.
Int63
(),
MsgID
:
rand
.
Int63
(),
},
},
SegmentIDs
:
[]
UniqueID
{
defaultSegmentID
},
SegmentIDs
:
[]
UniqueID
{},
CollectionID
:
defaultCollectionID
,
CollectionID
:
defaultCollectionID
,
}
}
...
@@ -401,9 +394,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -401,9 +394,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test GetSegmentInfo without streaming segment"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test GetSegmentInfo without streaming segment"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -412,7 +403,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -412,7 +403,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgID
:
rand
.
Int63
(),
MsgID
:
rand
.
Int63
(),
},
},
SegmentIDs
:
[]
UniqueID
{
defaultSegmentID
},
SegmentIDs
:
[]
UniqueID
{},
CollectionID
:
defaultCollectionID
,
CollectionID
:
defaultCollectionID
,
}
}
...
@@ -422,9 +413,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -422,9 +413,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test GetSegmentInfo without historical partition"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test GetSegmentInfo without historical partition"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -433,7 +422,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -433,7 +422,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgID
:
rand
.
Int63
(),
MsgID
:
rand
.
Int63
(),
},
},
SegmentIDs
:
[]
UniqueID
{
defaultSegmentID
},
SegmentIDs
:
[]
UniqueID
{},
CollectionID
:
defaultCollectionID
,
CollectionID
:
defaultCollectionID
,
}
}
...
@@ -443,9 +432,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -443,9 +432,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Add
(
1
)
t
.
Run
(
"test GetSegmentInfo without historical segment"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"test GetSegmentInfo without historical segment"
,
func
(
t
*
testing
.
T
)
{
defer
wg
.
Done
()
node
,
err
:=
genSimpleQueryNode
(
ctx
)
node
,
err
:=
genSimpleQueryNode
(
ctx
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
@@ -454,7 +441,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -454,7 +441,7 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgType
:
commonpb
.
MsgType_WatchQueryChannels
,
MsgID
:
rand
.
Int63
(),
MsgID
:
rand
.
Int63
(),
},
},
SegmentIDs
:
[]
UniqueID
{
defaultSegmentID
},
SegmentIDs
:
[]
UniqueID
{},
CollectionID
:
defaultCollectionID
,
CollectionID
:
defaultCollectionID
,
}
}
...
@@ -463,7 +450,6 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
...
@@ -463,7 +450,6 @@ func TestImpl_GetSegmentInfo(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
rsp
.
Status
.
ErrorCode
)
})
})
wg
.
Wait
()
}
}
func
TestImpl_isHealthy
(
t
*
testing
.
T
)
{
func
TestImpl_isHealthy
(
t
*
testing
.
T
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录