Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
a3630e17
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,发现更多精彩内容 >>
未验证
提交
a3630e17
编写于
6月 25, 2023
作者:
C
congqixia
提交者:
GitHub
6月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine grpc Status handling: retry legacy only for Unimplemented (#25041)
Signed-off-by:
N
Congqi Xia
<
congqi.xia@zilliz.com
>
上级
72c5e2a4
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
26 addition
and
9 deletion
+26
-9
internal/querycoordv2/meta/target_manager.go
internal/querycoordv2/meta/target_manager.go
+2
-1
internal/querycoordv2/meta/target_manager_test.go
internal/querycoordv2/meta/target_manager_test.go
+1
-1
internal/querynodev2/cluster/worker.go
internal/querynodev2/cluster/worker.go
+3
-2
internal/querynodev2/cluster/worker_test.go
internal/querynodev2/cluster/worker_test.go
+2
-2
pkg/util/funcutil/func.go
pkg/util/funcutil/func.go
+6
-3
pkg/util/funcutil/func_test.go
pkg/util/funcutil/func_test.go
+12
-0
未找到文件。
internal/querycoordv2/meta/target_manager.go
浏览文件 @
a3630e17
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/milvus-io/milvus/pkg/util/typeutil"
"github.com/milvus-io/milvus/pkg/util/typeutil"
"github.com/samber/lo"
"github.com/samber/lo"
"go.uber.org/zap"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
)
)
type
TargetScope
=
int32
type
TargetScope
=
int32
...
@@ -208,7 +209,7 @@ func (mgr *TargetManager) PullNextTarget(broker Broker, collectionID int64, chos
...
@@ -208,7 +209,7 @@ func (mgr *TargetManager) PullNextTarget(broker Broker, collectionID int64, chos
vChannelInfos
,
segmentInfos
,
err
:=
broker
.
GetRecoveryInfoV2
(
context
.
TODO
(),
collectionID
)
vChannelInfos
,
segmentInfos
,
err
:=
broker
.
GetRecoveryInfoV2
(
context
.
TODO
(),
collectionID
)
if
err
!=
nil
{
if
err
!=
nil
{
// if meet rpc error, for compatibility with previous versions, try pull next target v1
// if meet rpc error, for compatibility with previous versions, try pull next target v1
if
funcutil
.
IsGrpcErr
(
err
)
{
if
funcutil
.
IsGrpcErr
(
err
,
codes
.
Unimplemented
)
{
target
,
err
=
mgr
.
PullNextTargetV1
(
broker
,
collectionID
,
chosenPartitionIDs
...
)
target
,
err
=
mgr
.
PullNextTargetV1
(
broker
,
collectionID
,
chosenPartitionIDs
...
)
return
err
return
err
}
}
...
...
internal/querycoordv2/meta/target_manager_test.go
浏览文件 @
a3630e17
...
@@ -219,7 +219,7 @@ func (suite *TargetManagerSuite) TestUpdateNextTarget() {
...
@@ -219,7 +219,7 @@ func (suite *TargetManagerSuite) TestUpdateNextTarget() {
suite
.
broker
.
ExpectedCalls
=
nil
suite
.
broker
.
ExpectedCalls
=
nil
// test getRecoveryInfoV2 failed , then back to getRecoveryInfo succeed
// test getRecoveryInfoV2 failed , then back to getRecoveryInfo succeed
suite
.
broker
.
EXPECT
()
.
GetRecoveryInfoV2
(
mock
.
Anything
,
collectionID
)
.
Return
(
nil
,
nil
,
status
.
Errorf
(
codes
.
NotFoun
d
,
"fake not found"
))
suite
.
broker
.
EXPECT
()
.
GetRecoveryInfoV2
(
mock
.
Anything
,
collectionID
)
.
Return
(
nil
,
nil
,
status
.
Errorf
(
codes
.
Unimplemente
d
,
"fake not found"
))
suite
.
broker
.
EXPECT
()
.
GetPartitions
(
mock
.
Anything
,
mock
.
Anything
)
.
Return
([]
int64
{
1
},
nil
)
suite
.
broker
.
EXPECT
()
.
GetPartitions
(
mock
.
Anything
,
mock
.
Anything
)
.
Return
([]
int64
{
1
},
nil
)
suite
.
broker
.
EXPECT
()
.
GetRecoveryInfo
(
mock
.
Anything
,
collectionID
,
int64
(
1
))
.
Return
(
nextTargetChannels
,
nextTargetBinlogs
,
nil
)
suite
.
broker
.
EXPECT
()
.
GetRecoveryInfo
(
mock
.
Anything
,
collectionID
,
int64
(
1
))
.
Return
(
nextTargetChannels
,
nextTargetBinlogs
,
nil
)
err
:=
suite
.
mgr
.
UpdateCollectionNextTargetWithPartitions
(
collectionID
,
int64
(
1
))
err
:=
suite
.
mgr
.
UpdateCollectionNextTargetWithPartitions
(
collectionID
,
int64
(
1
))
...
...
internal/querynodev2/cluster/worker.go
浏览文件 @
a3630e17
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"fmt"
"fmt"
"go.uber.org/zap"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
...
@@ -120,7 +121,7 @@ func (w *remoteWorker) Delete(ctx context.Context, req *querypb.DeleteRequest) e
...
@@ -120,7 +121,7 @@ func (w *remoteWorker) Delete(ctx context.Context, req *querypb.DeleteRequest) e
func
(
w
*
remoteWorker
)
SearchSegments
(
ctx
context
.
Context
,
req
*
querypb
.
SearchRequest
)
(
*
internalpb
.
SearchResults
,
error
)
{
func
(
w
*
remoteWorker
)
SearchSegments
(
ctx
context
.
Context
,
req
*
querypb
.
SearchRequest
)
(
*
internalpb
.
SearchResults
,
error
)
{
ret
,
err
:=
w
.
client
.
SearchSegments
(
ctx
,
req
)
ret
,
err
:=
w
.
client
.
SearchSegments
(
ctx
,
req
)
if
err
!=
nil
&&
funcutil
.
IsGrpcErr
(
err
)
{
if
err
!=
nil
&&
funcutil
.
IsGrpcErr
(
err
,
codes
.
Unimplemented
)
{
// for compatible with rolling upgrade from version before v2.2.9
// for compatible with rolling upgrade from version before v2.2.9
return
w
.
client
.
Search
(
ctx
,
req
)
return
w
.
client
.
Search
(
ctx
,
req
)
}
}
...
@@ -130,7 +131,7 @@ func (w *remoteWorker) SearchSegments(ctx context.Context, req *querypb.SearchRe
...
@@ -130,7 +131,7 @@ func (w *remoteWorker) SearchSegments(ctx context.Context, req *querypb.SearchRe
func
(
w
*
remoteWorker
)
QuerySegments
(
ctx
context
.
Context
,
req
*
querypb
.
QueryRequest
)
(
*
internalpb
.
RetrieveResults
,
error
)
{
func
(
w
*
remoteWorker
)
QuerySegments
(
ctx
context
.
Context
,
req
*
querypb
.
QueryRequest
)
(
*
internalpb
.
RetrieveResults
,
error
)
{
ret
,
err
:=
w
.
client
.
QuerySegments
(
ctx
,
req
)
ret
,
err
:=
w
.
client
.
QuerySegments
(
ctx
,
req
)
if
err
!=
nil
&&
funcutil
.
IsGrpcErr
(
err
)
{
if
err
!=
nil
&&
funcutil
.
IsGrpcErr
(
err
,
codes
.
Unimplemented
)
{
// for compatible with rolling upgrade from version before v2.2.9
// for compatible with rolling upgrade from version before v2.2.9
return
w
.
client
.
Query
(
ctx
,
req
)
return
w
.
client
.
Query
(
ctx
,
req
)
}
}
...
...
internal/querynodev2/cluster/worker_test.go
浏览文件 @
a3630e17
...
@@ -238,7 +238,7 @@ func (s *RemoteWorkerSuite) TestSearch() {
...
@@ -238,7 +238,7 @@ func (s *RemoteWorkerSuite) TestSearch() {
var
result
*
internalpb
.
SearchResults
var
result
*
internalpb
.
SearchResults
var
err
error
var
err
error
grpcErr
:=
status
.
Error
(
codes
.
NotFoun
d
,
"method not implemented"
)
grpcErr
:=
status
.
Error
(
codes
.
Unimplemente
d
,
"method not implemented"
)
s
.
mockClient
.
EXPECT
()
.
SearchSegments
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.SearchRequest"
))
.
s
.
mockClient
.
EXPECT
()
.
SearchSegments
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.SearchRequest"
))
.
Return
(
result
,
grpcErr
)
Return
(
result
,
grpcErr
)
s
.
mockClient
.
EXPECT
()
.
Search
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.SearchRequest"
))
.
s
.
mockClient
.
EXPECT
()
.
Search
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.SearchRequest"
))
.
...
@@ -317,7 +317,7 @@ func (s *RemoteWorkerSuite) TestQuery() {
...
@@ -317,7 +317,7 @@ func (s *RemoteWorkerSuite) TestQuery() {
var
result
*
internalpb
.
RetrieveResults
var
result
*
internalpb
.
RetrieveResults
var
err
error
var
err
error
grpcErr
:=
status
.
Error
(
codes
.
NotFoun
d
,
"method not implemented"
)
grpcErr
:=
status
.
Error
(
codes
.
Unimplemente
d
,
"method not implemented"
)
s
.
mockClient
.
EXPECT
()
.
QuerySegments
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.QueryRequest"
))
.
s
.
mockClient
.
EXPECT
()
.
QuerySegments
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.QueryRequest"
))
.
Return
(
result
,
grpcErr
)
Return
(
result
,
grpcErr
)
s
.
mockClient
.
EXPECT
()
.
Query
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.QueryRequest"
))
.
s
.
mockClient
.
EXPECT
()
.
Query
(
mock
.
Anything
,
mock
.
AnythingOfType
(
"*querypb.QueryRequest"
))
.
...
...
pkg/util/funcutil/func.go
浏览文件 @
a3630e17
...
@@ -32,6 +32,8 @@ import (
...
@@ -32,6 +32,8 @@ import (
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
"github.com/milvus-io/milvus/pkg/util/typeutil"
"google.golang.org/grpc/codes"
grpcStatus
"google.golang.org/grpc/status"
grpcStatus
"google.golang.org/grpc/status"
)
)
...
@@ -279,14 +281,15 @@ func ReadBinary(endian binary.ByteOrder, bs []byte, receiver interface{}) error
...
@@ -279,14 +281,15 @@ func ReadBinary(endian binary.ByteOrder, bs []byte, receiver interface{}) error
}
}
// IsGrpcErr checks whether err is instance of grpc status error.
// IsGrpcErr checks whether err is instance of grpc status error.
func
IsGrpcErr
(
err
error
)
bool
{
func
IsGrpcErr
(
err
error
,
targets
...
codes
.
Code
)
bool
{
set
:=
typeutil
.
NewSet
[
codes
.
Code
](
targets
...
)
for
{
for
{
if
err
==
nil
{
if
err
==
nil
{
return
false
return
false
}
}
_
,
ok
:=
grpcStatus
.
FromError
(
err
)
s
,
ok
:=
grpcStatus
.
FromError
(
err
)
if
ok
{
if
ok
{
return
true
return
set
.
Len
()
==
0
||
set
.
Contain
(
s
.
Code
())
}
}
err
=
errors
.
Unwrap
(
err
)
err
=
errors
.
Unwrap
(
err
)
}
}
...
...
pkg/util/funcutil/func_test.go
浏览文件 @
a3630e17
...
@@ -349,6 +349,18 @@ func TestIsGrpcErr(t *testing.T) {
...
@@ -349,6 +349,18 @@ func TestIsGrpcErr(t *testing.T) {
errWrap
:=
fmt
.
Errorf
(
"wrap grpc error %w"
,
err
)
errWrap
:=
fmt
.
Errorf
(
"wrap grpc error %w"
,
err
)
assert
.
True
(
t
,
IsGrpcErr
(
errWrap
))
assert
.
True
(
t
,
IsGrpcErr
(
errWrap
))
})
})
t
.
Run
(
"codes_match"
,
func
(
t
*
testing
.
T
)
{
err
:=
grpcStatus
.
Error
(
grpcCodes
.
Unavailable
,
"test"
)
errWrap
:=
fmt
.
Errorf
(
"wrap grpc error %w"
,
err
)
assert
.
True
(
t
,
IsGrpcErr
(
errWrap
,
grpcCodes
.
Unimplemented
,
grpcCodes
.
Unavailable
))
})
t
.
Run
(
"codes_not_match"
,
func
(
t
*
testing
.
T
)
{
err
:=
grpcStatus
.
Error
(
grpcCodes
.
Unavailable
,
"test"
)
errWrap
:=
fmt
.
Errorf
(
"wrap grpc error %w"
,
err
)
assert
.
False
(
t
,
IsGrpcErr
(
errWrap
,
grpcCodes
.
Unimplemented
))
})
}
}
func
TestIsEmptyString
(
t
*
testing
.
T
)
{
func
TestIsEmptyString
(
t
*
testing
.
T
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录