Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
7dfab0aa
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
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 搜索 >>
未验证
提交
7dfab0aa
编写于
4月 29, 2022
作者:
Y
yah01
提交者:
GitHub
4月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add unit test for case of failed to sync segments to shard leader (#16712)
Signed-off-by:
N
yah01
<
yang.cen@zilliz.com
>
上级
97757405
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
13 deletion
+65
-13
internal/querycoord/impl_test.go
internal/querycoord/impl_test.go
+52
-0
internal/querycoord/mock_querynode_server_test.go
internal/querycoord/mock_querynode_server_test.go
+3
-3
internal/querycoord/task_test.go
internal/querycoord/task_test.go
+5
-5
internal/querycoord/util.go
internal/querycoord/util.go
+5
-5
未找到文件。
internal/querycoord/impl_test.go
浏览文件 @
7dfab0aa
...
...
@@ -94,6 +94,21 @@ func waitLoadCollectionDone(ctx context.Context, queryCoord *QueryCoord, collect
return
nil
}
func
waitLoadCollectionRollbackDone
(
queryCoord
*
QueryCoord
,
collectionID
UniqueID
)
bool
{
maxRetryNum
:=
100
for
cnt
:=
0
;
cnt
<
maxRetryNum
;
cnt
++
{
_
,
err
:=
queryCoord
.
meta
.
getCollectionInfoByID
(
collectionID
)
if
err
!=
nil
{
return
true
}
log
.
Debug
(
"waiting for rollback done..."
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
return
false
}
func
TestGrpcTask
(
t
*
testing
.
T
)
{
refreshParams
()
ctx
:=
context
.
Background
()
...
...
@@ -1024,6 +1039,43 @@ func TestLoadPartitionsWithReplicas(t *testing.T) {
assert
.
Nil
(
t
,
err
)
}
func
TestLoadCollectionSyncSegmentsFail
(
t
*
testing
.
T
)
{
refreshParams
()
ctx
:=
context
.
Background
()
defer
removeAllSession
()
queryCoord
,
err
:=
startQueryCoord
(
ctx
)
assert
.
Nil
(
t
,
err
)
defer
queryCoord
.
Stop
()
node1
,
err
:=
startQueryNodeServer
(
ctx
)
assert
.
Nil
(
t
,
err
)
waitQueryNodeOnline
(
queryCoord
.
cluster
,
node1
.
queryNodeID
)
defer
node1
.
stop
()
node1
.
syncReplicaSegments
=
returnFailedResult
// Failed to sync segments should cause rollback
loadCollectionReq
:=
&
querypb
.
LoadCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_LoadCollection
,
},
CollectionID
:
defaultCollectionID
,
Schema
:
genDefaultCollectionSchema
(
false
),
ReplicaNumber
:
1
,
}
status
,
err
:=
queryCoord
.
LoadCollection
(
ctx
,
loadCollectionReq
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
status
.
ErrorCode
)
// Wait for rollback done
rollbackDone
:=
waitLoadCollectionRollbackDone
(
queryCoord
,
loadCollectionReq
.
CollectionID
)
assert
.
True
(
t
,
rollbackDone
)
assert
.
NoError
(
t
,
node1
.
stop
())
assert
.
NoError
(
t
,
queryCoord
.
Stop
())
assert
.
NoError
(
t
,
removeAllSession
())
}
func
Test_RepeatedLoadSamePartitions
(
t
*
testing
.
T
)
{
refreshParams
()
ctx
:=
context
.
Background
()
...
...
internal/querycoord/mock_querynode_server_test.go
浏览文件 @
7dfab0aa
...
...
@@ -71,6 +71,7 @@ type queryNodeServerMock struct {
releaseCollection
rpcHandler
releasePartition
rpcHandler
releaseSegments
rpcHandler
syncReplicaSegments
rpcHandler
getSegmentInfos
func
()
(
*
querypb
.
GetSegmentInfoResponse
,
error
)
getMetrics
func
()
(
*
milvuspb
.
GetMetricsResponse
,
error
)
...
...
@@ -95,6 +96,7 @@ func newQueryNodeServerMock(ctx context.Context) *queryNodeServerMock {
releaseCollection
:
returnSuccessResult
,
releasePartition
:
returnSuccessResult
,
releaseSegments
:
returnSuccessResult
,
syncReplicaSegments
:
returnSuccessResult
,
getSegmentInfos
:
returnSuccessGetSegmentInfoResult
,
getMetrics
:
returnSuccessGetMetricsResult
,
...
...
@@ -273,9 +275,7 @@ func (qs *queryNodeServerMock) GetSegmentInfo(ctx context.Context, req *querypb.
}
func
(
qs
*
queryNodeServerMock
)
SyncReplicaSegments
(
ctx
context
.
Context
,
req
*
querypb
.
SyncReplicaSegmentsRequest
)
(
*
commonpb
.
Status
,
error
)
{
return
&
commonpb
.
Status
{
ErrorCode
:
commonpb
.
ErrorCode_Success
,
},
nil
return
qs
.
syncReplicaSegments
()
}
func
(
qs
*
queryNodeServerMock
)
GetMetrics
(
ctx
context
.
Context
,
req
*
milvuspb
.
GetMetricsRequest
)
(
*
milvuspb
.
GetMetricsResponse
,
error
)
{
...
...
internal/querycoord/task_test.go
浏览文件 @
7dfab0aa
...
...
@@ -480,8 +480,11 @@ func Test_LoadCollectionExecuteFail(t *testing.T) {
func
TestLoadCollectionNoEnoughNodeFail
(
t
*
testing
.
T
)
{
refreshParams
()
ctx
:=
context
.
Background
()
defer
removeAllSession
()
queryCoord
,
err
:=
startQueryCoord
(
ctx
)
assert
.
Nil
(
t
,
err
)
defer
queryCoord
.
Stop
()
node1
,
err
:=
startQueryNodeServer
(
ctx
)
assert
.
Nil
(
t
,
err
)
...
...
@@ -489,16 +492,13 @@ func TestLoadCollectionNoEnoughNodeFail(t *testing.T) {
assert
.
Nil
(
t
,
err
)
waitQueryNodeOnline
(
queryCoord
.
cluster
,
node1
.
queryNodeID
)
waitQueryNodeOnline
(
queryCoord
.
cluster
,
node2
.
queryNodeID
)
defer
node1
.
stop
()
defer
node2
.
stop
()
loadCollectionTask
:=
genLoadCollectionTask
(
ctx
,
queryCoord
)
loadCollectionTask
.
ReplicaNumber
=
3
err
=
queryCoord
.
scheduler
.
processTask
(
loadCollectionTask
)
assert
.
Error
(
t
,
err
)
assert
.
NoError
(
t
,
node1
.
stop
())
assert
.
NoError
(
t
,
node2
.
stop
())
assert
.
NoError
(
t
,
queryCoord
.
Stop
())
assert
.
NoError
(
t
,
removeAllSession
())
}
func
Test_LoadPartitionAssignTaskFail
(
t
*
testing
.
T
)
{
...
...
internal/querycoord/util.go
浏览文件 @
7dfab0aa
...
...
@@ -168,12 +168,12 @@ func syncReplicaSegments(ctx context.Context, cluster Cluster, childTasks []task
}
for
dmc
,
leaders
:=
range
shardLeaders
{
for
_
,
leader
:=
range
leaders
{
segments
,
ok
:=
shardSegments
[
dmc
]
if
!
ok
{
break
}
segments
,
ok
:=
shardSegments
[
dmc
]
if
!
ok
{
continue
}
for
_
,
leader
:=
range
leaders
{
req
:=
querypb
.
SyncReplicaSegmentsRequest
{
VchannelName
:
dmc
,
ReplicaSegments
:
make
([]
*
querypb
.
ReplicaSegmentsInfo
,
0
,
len
(
segments
)),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录