Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
e6d2849c
M
milvus
项目概览
milvus
/
milvus
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
e6d2849c
编写于
12月 29, 2022
作者:
S
SimFG
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check whether the node is stopping when using `load balance` api (#21438)
Signed-off-by:
N
SimFG
<
bang.fu@zilliz.com
>
上级
d7156812
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
0 deletion
+42
-0
internal/querycoordv2/services.go
internal/querycoordv2/services.go
+22
-0
internal/querycoordv2/services_test.go
internal/querycoordv2/services_test.go
+20
-0
未找到文件。
internal/querycoordv2/services.go
浏览文件 @
e6d2849c
...
...
@@ -444,6 +444,20 @@ func (s *Server) GetSegmentInfo(ctx context.Context, req *querypb.GetSegmentInfo
},
nil
}
func
(
s
*
Server
)
isStoppingNode
(
nodeID
int64
)
error
{
isStopping
,
err
:=
s
.
nodeMgr
.
IsStoppingNode
(
nodeID
)
if
err
!=
nil
{
log
.
Warn
(
"fail to check whether the node is stopping"
,
zap
.
Int64
(
"node_id"
,
nodeID
),
zap
.
Error
(
err
))
return
err
}
if
isStopping
{
msg
:=
fmt
.
Sprintf
(
"failed to balance due to the source/destination node[%d] is stopping"
,
nodeID
)
log
.
Warn
(
msg
)
return
errors
.
New
(
msg
)
}
return
nil
}
func
(
s
*
Server
)
LoadBalance
(
ctx
context
.
Context
,
req
*
querypb
.
LoadBalanceRequest
)
(
*
commonpb
.
Status
,
error
)
{
log
:=
log
.
Ctx
(
ctx
)
.
With
(
zap
.
Int64
(
"collectionID"
,
req
.
GetCollectionID
()),
...
...
@@ -478,12 +492,20 @@ func (s *Server) LoadBalance(ctx context.Context, req *querypb.LoadBalanceReques
log
.
Warn
(
msg
)
return
utils
.
WrapStatus
(
commonpb
.
ErrorCode_UnexpectedError
,
msg
),
nil
}
if
err
:=
s
.
isStoppingNode
(
srcNode
);
err
!=
nil
{
return
utils
.
WrapStatus
(
commonpb
.
ErrorCode_UnexpectedError
,
fmt
.
Sprintf
(
"can't balance, because the source node[%d] is invalid"
,
srcNode
),
err
),
nil
}
for
_
,
dstNode
:=
range
req
.
GetDstNodeIDs
()
{
if
!
replica
.
Nodes
.
Contain
(
dstNode
)
{
msg
:=
"destination nodes have to be in the same replica of source node"
log
.
Warn
(
msg
)
return
utils
.
WrapStatus
(
commonpb
.
ErrorCode_UnexpectedError
,
msg
),
nil
}
if
err
:=
s
.
isStoppingNode
(
dstNode
);
err
!=
nil
{
return
utils
.
WrapStatus
(
commonpb
.
ErrorCode_UnexpectedError
,
fmt
.
Sprintf
(
"can't balance, because the destination node[%d] is invalid"
,
dstNode
),
err
),
nil
}
}
err
:=
s
.
balanceSegments
(
ctx
,
req
,
replica
)
...
...
internal/querycoordv2/services_test.go
浏览文件 @
e6d2849c
...
...
@@ -745,6 +745,26 @@ func (suite *ServiceSuite) TestLoadBalanceFailed() {
suite
.
Equal
(
commonpb
.
ErrorCode_UnexpectedError
,
resp
.
ErrorCode
)
suite
.
Contains
(
resp
.
Reason
,
"failed to balance segments"
)
suite
.
Contains
(
resp
.
Reason
,
task
.
ErrTaskCanceled
.
Error
())
suite
.
meta
.
ReplicaManager
.
AddNode
(
replicas
[
0
]
.
ID
,
10
)
req
.
SourceNodeIDs
=
[]
int64
{
10
}
resp
,
err
=
server
.
LoadBalance
(
ctx
,
req
)
suite
.
NoError
(
err
)
suite
.
Equal
(
commonpb
.
ErrorCode_UnexpectedError
,
resp
.
ErrorCode
)
req
.
SourceNodeIDs
=
[]
int64
{
srcNode
}
req
.
DstNodeIDs
=
[]
int64
{
10
}
resp
,
err
=
server
.
LoadBalance
(
ctx
,
req
)
suite
.
NoError
(
err
)
suite
.
Equal
(
commonpb
.
ErrorCode_UnexpectedError
,
resp
.
ErrorCode
)
suite
.
nodeMgr
.
Add
(
session
.
NewNodeInfo
(
10
,
"localhost"
))
suite
.
nodeMgr
.
Stopping
(
10
)
resp
,
err
=
server
.
LoadBalance
(
ctx
,
req
)
suite
.
NoError
(
err
)
suite
.
Equal
(
commonpb
.
ErrorCode_UnexpectedError
,
resp
.
ErrorCode
)
suite
.
nodeMgr
.
Remove
(
10
)
suite
.
meta
.
ReplicaManager
.
RemoveNode
(
replicas
[
0
]
.
ID
,
10
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录