Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
235d736a
M
milvus
项目概览
milvus
/
milvus
10 个月 前同步成功
通知
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 搜索 >>
未验证
提交
235d736a
编写于
10月 11, 2021
作者:
X
xige-16
提交者:
GitHub
10月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add max number of retries for interTask in querycoord (#8215)
Signed-off-by:
N
xige-16
<
xi.ge@zilliz.com
>
上级
bd3a8ed3
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
1721 addition
and
788 deletion
+1721
-788
internal/querycoord/cluster.go
internal/querycoord/cluster.go
+1
-0
internal/querycoord/impl.go
internal/querycoord/impl.go
+36
-28
internal/querycoord/impl_test.go
internal/querycoord/impl_test.go
+85
-2
internal/querycoord/meta.go
internal/querycoord/meta.go
+6
-8
internal/querycoord/mock_3rd_component_test.go
internal/querycoord/mock_3rd_component_test.go
+65
-33
internal/querycoord/query_coord.go
internal/querycoord/query_coord.go
+11
-13
internal/querycoord/query_coord_test.go
internal/querycoord/query_coord_test.go
+5
-0
internal/querycoord/task.go
internal/querycoord/task.go
+503
-321
internal/querycoord/task_scheduler.go
internal/querycoord/task_scheduler.go
+379
-285
internal/querycoord/task_scheduler_test.go
internal/querycoord/task_scheduler_test.go
+31
-24
internal/querycoord/task_test.go
internal/querycoord/task_test.go
+599
-74
未找到文件。
internal/querycoord/cluster.go
浏览文件 @
235d736a
...
...
@@ -374,6 +374,7 @@ func (c *queryNodeCluster) releasePartitions(ctx context.Context, nodeID int64,
log
.
Debug
(
"ReleasePartitions: queryNode release partitions error"
,
zap
.
String
(
"error"
,
err
.
Error
()))
return
err
}
for
_
,
partitionID
:=
range
in
.
PartitionIDs
{
err
=
c
.
clusterMeta
.
releasePartition
(
in
.
CollectionID
,
partitionID
)
if
err
!=
nil
{
...
...
internal/querycoord/impl.go
浏览文件 @
235d736a
...
...
@@ -141,21 +141,23 @@ func (qc *QueryCoord) LoadCollection(ctx context.Context, req *querypb.LoadColle
return
status
,
err
}
baseTask
:=
newBaseTask
(
qc
.
loopCtx
,
querypb
.
TriggerCondition_grpcRequest
)
loadCollectionTask
:=
&
LoadCollectionTask
{
BaseTask
:
BaseTask
{
ctx
:
qc
.
loopCtx
,
Condition
:
NewTaskCondition
(
qc
.
loopCtx
),
triggerCondition
:
querypb
.
TriggerCondition_grpcRequest
,
},
BaseTask
:
baseTask
,
LoadCollectionRequest
:
req
,
rootCoord
:
qc
.
rootCoordClient
,
dataCoord
:
qc
.
dataCoordClient
,
cluster
:
qc
.
cluster
,
meta
:
qc
.
meta
,
}
qc
.
scheduler
.
Enqueue
([]
task
{
loadCollectionTask
})
err
:=
qc
.
scheduler
.
Enqueue
(
loadCollectionTask
)
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
return
status
,
err
}
err
:
=
loadCollectionTask
.
WaitToFinish
()
err
=
loadCollectionTask
.
WaitToFinish
()
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
...
...
@@ -188,20 +190,22 @@ func (qc *QueryCoord) ReleaseCollection(ctx context.Context, req *querypb.Releas
return
status
,
nil
}
baseTask
:=
newBaseTask
(
qc
.
loopCtx
,
querypb
.
TriggerCondition_grpcRequest
)
releaseCollectionTask
:=
&
ReleaseCollectionTask
{
BaseTask
:
BaseTask
{
ctx
:
qc
.
loopCtx
,
Condition
:
NewTaskCondition
(
qc
.
loopCtx
),
triggerCondition
:
querypb
.
TriggerCondition_grpcRequest
,
},
BaseTask
:
baseTask
,
ReleaseCollectionRequest
:
req
,
cluster
:
qc
.
cluster
,
meta
:
qc
.
meta
,
rootCoord
:
qc
.
rootCoordClient
,
}
qc
.
scheduler
.
Enqueue
([]
task
{
releaseCollectionTask
})
err
:=
qc
.
scheduler
.
Enqueue
(
releaseCollectionTask
)
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
return
status
,
err
}
err
:
=
releaseCollectionTask
.
WaitToFinish
()
err
=
releaseCollectionTask
.
WaitToFinish
()
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
...
...
@@ -329,20 +333,22 @@ func (qc *QueryCoord) LoadPartitions(ctx context.Context, req *querypb.LoadParti
req
.
PartitionIDs
=
partitionIDsToLoad
}
baseTask
:=
newBaseTask
(
qc
.
loopCtx
,
querypb
.
TriggerCondition_grpcRequest
)
loadPartitionTask
:=
&
LoadPartitionTask
{
BaseTask
:
BaseTask
{
ctx
:
qc
.
loopCtx
,
Condition
:
NewTaskCondition
(
qc
.
loopCtx
),
triggerCondition
:
querypb
.
TriggerCondition_grpcRequest
,
},
BaseTask
:
baseTask
,
LoadPartitionsRequest
:
req
,
dataCoord
:
qc
.
dataCoordClient
,
cluster
:
qc
.
cluster
,
meta
:
qc
.
meta
,
}
qc
.
scheduler
.
Enqueue
([]
task
{
loadPartitionTask
})
err
:=
qc
.
scheduler
.
Enqueue
(
loadPartitionTask
)
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
return
status
,
err
}
err
:
=
loadPartitionTask
.
WaitToFinish
()
err
=
loadPartitionTask
.
WaitToFinish
()
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
...
...
@@ -398,18 +404,20 @@ func (qc *QueryCoord) ReleasePartitions(ctx context.Context, req *querypb.Releas
}
req
.
PartitionIDs
=
toReleasedPartitions
baseTask
:=
newBaseTask
(
qc
.
loopCtx
,
querypb
.
TriggerCondition_grpcRequest
)
releasePartitionTask
:=
&
ReleasePartitionTask
{
BaseTask
:
BaseTask
{
ctx
:
qc
.
loopCtx
,
Condition
:
NewTaskCondition
(
qc
.
loopCtx
),
triggerCondition
:
querypb
.
TriggerCondition_grpcRequest
,
},
BaseTask
:
baseTask
,
ReleasePartitionsRequest
:
req
,
cluster
:
qc
.
cluster
,
}
qc
.
scheduler
.
Enqueue
([]
task
{
releasePartitionTask
})
err
:=
qc
.
scheduler
.
Enqueue
(
releasePartitionTask
)
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
return
status
,
err
}
err
:
=
releasePartitionTask
.
WaitToFinish
()
err
=
releasePartitionTask
.
WaitToFinish
()
if
err
!=
nil
{
status
.
ErrorCode
=
commonpb
.
ErrorCode_UnexpectedError
status
.
Reason
=
err
.
Error
()
...
...
internal/querycoord/impl_test.go
浏览文件 @
235d736a
...
...
@@ -13,6 +13,7 @@ package querycoord
import
(
"context"
"encoding/json"
"errors"
"testing"
"time"
...
...
@@ -328,6 +329,87 @@ func TestGrpcTask(t *testing.T) {
assert
.
Nil
(
t
,
err
)
}
func
TestGrpcTaskEnqueueFail
(
t
*
testing
.
T
)
{
refreshParams
()
ctx
:=
context
.
Background
()
queryCoord
,
err
:=
startQueryCoord
(
ctx
)
assert
.
Nil
(
t
,
err
)
_
,
err
=
startQueryNodeServer
(
ctx
)
assert
.
Nil
(
t
,
err
)
taskIDAllocator
:=
queryCoord
.
scheduler
.
taskIDAllocator
failedAllocator
:=
func
()
(
UniqueID
,
error
)
{
return
0
,
errors
.
New
(
"scheduler failed to allocate ID"
)
}
queryCoord
.
scheduler
.
taskIDAllocator
=
failedAllocator
t
.
Run
(
"Test LoadPartition"
,
func
(
t
*
testing
.
T
)
{
status
,
err
:=
queryCoord
.
LoadPartitions
(
ctx
,
&
querypb
.
LoadPartitionsRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_LoadPartitions
,
},
CollectionID
:
defaultCollectionID
,
PartitionIDs
:
[]
UniqueID
{
defaultPartitionID
},
Schema
:
genCollectionSchema
(
defaultCollectionID
,
false
),
})
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
status
.
ErrorCode
)
assert
.
NotNil
(
t
,
err
)
})
t
.
Run
(
"Test LoadCollection"
,
func
(
t
*
testing
.
T
)
{
status
,
err
:=
queryCoord
.
LoadCollection
(
ctx
,
&
querypb
.
LoadCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_LoadCollection
,
},
CollectionID
:
defaultCollectionID
,
Schema
:
genCollectionSchema
(
defaultCollectionID
,
false
),
})
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
status
.
ErrorCode
)
assert
.
NotNil
(
t
,
err
)
})
queryCoord
.
scheduler
.
taskIDAllocator
=
taskIDAllocator
status
,
err
:=
queryCoord
.
LoadCollection
(
ctx
,
&
querypb
.
LoadCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_LoadCollection
,
},
CollectionID
:
defaultCollectionID
,
Schema
:
genCollectionSchema
(
defaultCollectionID
,
false
),
})
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_Success
,
status
.
ErrorCode
)
assert
.
Nil
(
t
,
err
)
queryCoord
.
scheduler
.
taskIDAllocator
=
failedAllocator
t
.
Run
(
"Test ReleasePartition"
,
func
(
t
*
testing
.
T
)
{
status
,
err
:=
queryCoord
.
ReleasePartitions
(
ctx
,
&
querypb
.
ReleasePartitionsRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_ReleasePartitions
,
},
CollectionID
:
defaultCollectionID
,
PartitionIDs
:
[]
UniqueID
{
defaultPartitionID
},
})
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
status
.
ErrorCode
)
assert
.
NotNil
(
t
,
err
)
})
t
.
Run
(
"Test ReleaseCollection"
,
func
(
t
*
testing
.
T
)
{
status
,
err
:=
queryCoord
.
ReleaseCollection
(
ctx
,
&
querypb
.
ReleaseCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_ReleaseCollection
,
},
CollectionID
:
defaultCollectionID
,
})
assert
.
Equal
(
t
,
commonpb
.
ErrorCode_UnexpectedError
,
status
.
ErrorCode
)
assert
.
NotNil
(
t
,
err
)
})
queryCoord
.
Stop
()
err
=
removeAllSession
()
assert
.
Nil
(
t
,
err
)
}
func
TestLoadBalanceTask
(
t
*
testing
.
T
)
{
refreshParams
()
baseCtx
:=
context
.
Background
()
...
...
@@ -371,7 +453,7 @@ func TestLoadBalanceTask(t *testing.T) {
}
loadBalanceTask
:=
&
LoadBalanceTask
{
BaseTask
:
BaseTask
{
BaseTask
:
&
BaseTask
{
ctx
:
baseCtx
,
Condition
:
NewTaskCondition
(
baseCtx
),
triggerCondition
:
querypb
.
TriggerCondition_nodeDown
,
...
...
@@ -382,7 +464,7 @@ func TestLoadBalanceTask(t *testing.T) {
cluster
:
queryCoord
.
cluster
,
meta
:
queryCoord
.
meta
,
}
queryCoord
.
scheduler
.
Enqueue
(
[]
task
{
loadBalanceTask
}
)
queryCoord
.
scheduler
.
Enqueue
(
loadBalanceTask
)
res
,
err
=
queryCoord
.
ReleaseCollection
(
baseCtx
,
&
querypb
.
ReleaseCollectionRequest
{
Base
:
&
commonpb
.
MsgBase
{
...
...
@@ -400,6 +482,7 @@ func TestLoadBalanceTask(t *testing.T) {
}
func
TestGrpcTaskBeforeHealthy
(
t
*
testing
.
T
)
{
refreshParams
()
ctx
:=
context
.
Background
()
unHealthyCoord
,
err
:=
startUnHealthyQueryCoord
(
ctx
)
assert
.
Nil
(
t
,
err
)
...
...
internal/querycoord/meta.go
浏览文件 @
235d736a
...
...
@@ -423,25 +423,23 @@ func (m *MetaReplica) releaseCollection(collectionID UniqueID) error {
defer
m
.
Unlock
()
delete
(
m
.
collectionInfos
,
collectionID
)
var
err
error
for
id
,
info
:=
range
m
.
segmentInfos
{
if
info
.
CollectionID
==
collectionID
{
err
:
=
removeSegmentInfo
(
id
,
m
.
client
)
err
=
removeSegmentInfo
(
id
,
m
.
client
)
if
err
!=
nil
{
log
.
Error
(
"remove segmentInfo error"
,
zap
.
Any
(
"error"
,
err
.
Error
()),
zap
.
Int64
(
"segmentID"
,
id
))
return
err
log
.
Warn
(
"remove segmentInfo error"
,
zap
.
Any
(
"error"
,
err
.
Error
()),
zap
.
Int64
(
"segmentID"
,
id
))
}
delete
(
m
.
segmentInfos
,
id
)
}
}
delete
(
m
.
queryChannelInfos
,
collectionID
)
err
:=
removeGlobalCollectionInfo
(
collectionID
,
m
.
client
)
err
=
removeGlobalCollectionInfo
(
collectionID
,
m
.
client
)
if
err
!=
nil
{
log
.
Error
(
"remove collectionInfo error"
,
zap
.
Any
(
"error"
,
err
.
Error
()),
zap
.
Int64
(
"collectionID"
,
collectionID
))
return
err
log
.
Warn
(
"remove collectionInfo error"
,
zap
.
Any
(
"error"
,
err
.
Error
()),
zap
.
Int64
(
"collectionID"
,
collectionID
))
}
return
nil
return
err
}
func
(
m
*
MetaReplica
)
releasePartition
(
collectionID
UniqueID
,
partitionID
UniqueID
)
error
{
...
...
internal/querycoord/mock_3rd_component_test.go
浏览文件 @
235d736a
...
...
@@ -214,7 +214,9 @@ func (rc *rootCoordMock) createCollection(collectionID UniqueID) {
if
_
,
ok
:=
rc
.
Col2partition
[
collectionID
];
!
ok
{
rc
.
CollectionIDs
=
append
(
rc
.
CollectionIDs
,
collectionID
)
rc
.
Col2partition
[
collectionID
]
=
make
([]
UniqueID
,
0
)
partitionIDs
:=
make
([]
UniqueID
,
0
)
partitionIDs
=
append
(
partitionIDs
,
defaultPartitionID
+
1
)
rc
.
Col2partition
[
collectionID
]
=
partitionIDs
}
}
...
...
@@ -222,13 +224,30 @@ func (rc *rootCoordMock) createPartition(collectionID UniqueID, partitionID Uniq
rc
.
Lock
()
defer
rc
.
Unlock
()
if
_
,
ok
:=
rc
.
Col2partition
[
collectionID
];
ok
{
rc
.
Col2partition
[
collectionID
]
=
append
(
rc
.
Col2partition
[
collectionID
],
partitionID
)
if
partitionIDs
,
ok
:=
rc
.
Col2partition
[
collectionID
];
ok
{
partitionExist
:=
false
for
_
,
id
:=
range
partitionIDs
{
if
id
==
partitionID
{
partitionExist
=
true
break
}
}
if
!
partitionExist
{
rc
.
Col2partition
[
collectionID
]
=
append
(
rc
.
Col2partition
[
collectionID
],
partitionID
)
}
return
nil
}
return
errors
.
New
(
"collection not exist"
)
}
func
(
rc
*
rootCoordMock
)
CreatePartition
(
ctx
context
.
Context
,
req
*
milvuspb
.
CreatePartitionRequest
)
(
*
commonpb
.
Status
,
error
)
{
rc
.
createPartition
(
defaultCollectionID
,
defaultPartitionID
)
return
&
commonpb
.
Status
{
ErrorCode
:
commonpb
.
ErrorCode_Success
,
},
nil
}
func
(
rc
*
rootCoordMock
)
ShowPartitions
(
ctx
context
.
Context
,
in
*
milvuspb
.
ShowPartitionsRequest
)
(
*
milvuspb
.
ShowPartitionsResponse
,
error
)
{
collectionID
:=
in
.
CollectionID
status
:=
&
commonpb
.
Status
{
...
...
@@ -244,7 +263,6 @@ func (rc *rootCoordMock) ShowPartitions(ctx context.Context, in *milvuspb.ShowPa
}
rc
.
createCollection
(
collectionID
)
rc
.
createPartition
(
collectionID
,
defaultPartitionID
)
return
&
milvuspb
.
ShowPartitionsResponse
{
Status
:
status
,
...
...
@@ -267,16 +285,17 @@ type dataCoordMock struct {
minioKV
kv
.
BaseKV
collections
[]
UniqueID
col2DmChannels
map
[
UniqueID
][]
*
datapb
.
VchannelInfo
partitionID2Segment
map
[
UniqueID
]
UniqueID
Segment2Binlog
map
[
UniqueID
][]
*
datapb
.
SegmentBinlogs
assignedSegmentID
UniqueID
partitionID2Segment
map
[
UniqueID
][]
UniqueID
Segment2Binlog
map
[
UniqueID
]
*
datapb
.
SegmentBinlogs
baseSegmentID
UniqueID
channelNumPerCol
int
}
func
newDataCoordMock
(
ctx
context
.
Context
)
(
*
dataCoordMock
,
error
)
{
collectionIDs
:=
make
([]
UniqueID
,
0
)
col2DmChannels
:=
make
(
map
[
UniqueID
][]
*
datapb
.
VchannelInfo
)
partitionID2Segment
:=
make
(
map
[
UniqueID
]
UniqueID
)
segment2Binglog
:=
make
(
map
[
UniqueID
]
[]
*
datapb
.
SegmentBinlogs
)
partitionID2Segment
s
:=
make
(
map
[
UniqueID
][
]
UniqueID
)
segment2Binglog
:=
make
(
map
[
UniqueID
]
*
datapb
.
SegmentBinlogs
)
// create minio client
option
:=
&
minioKV
.
Option
{
...
...
@@ -296,9 +315,10 @@ func newDataCoordMock(ctx context.Context) (*dataCoordMock, error) {
minioKV
:
kv
,
collections
:
collectionIDs
,
col2DmChannels
:
col2DmChannels
,
partitionID2Segment
:
partitionID2Segment
,
partitionID2Segment
:
partitionID2Segment
s
,
Segment2Binlog
:
segment2Binglog
,
assignedSegmentID
:
defaultSegmentID
,
baseSegmentID
:
defaultSegmentID
,
channelNumPerCol
:
2
,
},
nil
}
...
...
@@ -306,28 +326,36 @@ func (data *dataCoordMock) GetRecoveryInfo(ctx context.Context, req *datapb.GetR
collectionID
:=
req
.
CollectionID
partitionID
:=
req
.
PartitionID
if
_
,
ok
:=
data
.
col2DmChannels
[
collectionID
];
!
ok
{
segmentID
:=
data
.
assignedSegmentID
data
.
partitionID2Segment
[
partitionID
]
=
segmentID
fieldID2Paths
,
err
:=
generateInsertBinLog
(
collectionID
,
partitionID
,
segmentID
,
"queryCoorf-mockDataCoord"
,
data
.
minioKV
)
if
err
!=
nil
{
return
nil
,
err
}
fieldBinlogs
:=
make
([]
*
datapb
.
FieldBinlog
,
0
)
for
fieldID
,
path
:=
range
fieldID2Paths
{
fieldBinlog
:=
&
datapb
.
FieldBinlog
{
FieldID
:
fieldID
,
Binlogs
:
[]
string
{
path
},
if
_
,
ok
:=
data
.
partitionID2Segment
[
partitionID
];
!
ok
{
segmentIDs
:=
make
([]
UniqueID
,
0
)
for
i
:=
0
;
i
<
data
.
channelNumPerCol
;
i
++
{
segmentID
:=
data
.
baseSegmentID
if
_
,
ok
:=
data
.
Segment2Binlog
[
segmentID
];
!
ok
{
fieldID2Paths
,
err
:=
generateInsertBinLog
(
collectionID
,
partitionID
,
segmentID
,
"queryCoorf-mockDataCoord"
,
data
.
minioKV
)
if
err
!=
nil
{
return
nil
,
err
}
fieldBinlogs
:=
make
([]
*
datapb
.
FieldBinlog
,
0
)
for
fieldID
,
path
:=
range
fieldID2Paths
{
fieldBinlog
:=
&
datapb
.
FieldBinlog
{
FieldID
:
fieldID
,
Binlogs
:
[]
string
{
path
},
}
fieldBinlogs
=
append
(
fieldBinlogs
,
fieldBinlog
)
}
segmentBinlog
:=
&
datapb
.
SegmentBinlogs
{
SegmentID
:
segmentID
,
FieldBinlogs
:
fieldBinlogs
,
}
data
.
Segment2Binlog
[
segmentID
]
=
segmentBinlog
}
fieldBinlogs
=
append
(
fieldBinlogs
,
fieldBinlog
)
}
data
.
Segment2Binlog
[
segmentID
]
=
make
([]
*
datapb
.
SegmentBinlogs
,
0
)
segmentBinlog
:=
&
datapb
.
SegmentBinlogs
{
SegmentID
:
segmentID
,
FieldBinlogs
:
fieldBinlogs
,
segmentIDs
=
append
(
segmentIDs
,
segmentID
)
data
.
baseSegmentID
++
}
data
.
Segment2Binlog
[
segmentID
]
=
append
(
data
.
Segment2Binlog
[
segmentID
],
segmentBinlog
)
data
.
partitionID2Segment
[
partitionID
]
=
segmentIDs
}
if
_
,
ok
:=
data
.
col2DmChannels
[
collectionID
];
!
ok
{
channelInfos
:=
make
([]
*
datapb
.
VchannelInfo
,
0
)
data
.
collections
=
append
(
data
.
collections
,
collectionID
)
collectionName
:=
funcutil
.
RandomString
(
8
)
...
...
@@ -339,20 +367,24 @@ func (data *dataCoordMock) GetRecoveryInfo(ctx context.Context, req *datapb.GetR
SeekPosition
:
&
internalpb
.
MsgPosition
{
ChannelName
:
vChannel
,
},
FlushedSegments
:
[]
*
datapb
.
SegmentInfo
{{
ID
:
segmentID
}},
}
channelInfos
=
append
(
channelInfos
,
channelInfo
)
}
data
.
col2DmChannels
[
collectionID
]
=
channelInfos
}
segmentID
:=
data
.
partitionID2Segment
[
partitionID
]
binlogs
:=
make
([]
*
datapb
.
SegmentBinlogs
,
0
)
for
_
,
segmentID
:=
range
data
.
partitionID2Segment
[
partitionID
]
{
if
_
,
ok
:=
data
.
Segment2Binlog
[
segmentID
];
ok
{
binlogs
=
append
(
binlogs
,
data
.
Segment2Binlog
[
segmentID
])
}
}
return
&
datapb
.
GetRecoveryInfoResponse
{
Status
:
&
commonpb
.
Status
{
ErrorCode
:
commonpb
.
ErrorCode_Success
,
},
Channels
:
data
.
col2DmChannels
[
collectionID
],
Binlogs
:
data
.
Segment2Binlog
[
segmentID
]
,
Binlogs
:
binlogs
,
},
nil
}
...
...
internal/querycoord/query_coord.go
浏览文件 @
235d736a
...
...
@@ -87,6 +87,8 @@ func (qc *QueryCoord) Register() error {
// Init function initializes the queryCoord's meta, cluster, etcdKV and task scheduler
func
(
qc
*
QueryCoord
)
Init
()
error
{
log
.
Debug
(
"query coordinator start init"
)
//connect etcd
connectEtcdFn
:=
func
()
error
{
etcdKV
,
err
:=
etcdkv
.
NewEtcdKV
(
Params
.
EtcdEndpoints
,
Params
.
MetaRootPath
)
if
err
!=
nil
{
...
...
@@ -221,19 +223,17 @@ func (qc *QueryCoord) watchNodeLoop() {
SourceNodeIDs
:
offlineNodeIDs
,
}
baseTask
:=
newBaseTask
(
qc
.
loopCtx
,
querypb
.
TriggerCondition_nodeDown
)
loadBalanceTask
:=
&
LoadBalanceTask
{
BaseTask
:
BaseTask
{
ctx
:
qc
.
loopCtx
,
Condition
:
NewTaskCondition
(
qc
.
loopCtx
),
triggerCondition
:
querypb
.
TriggerCondition_nodeDown
,
},
BaseTask
:
baseTask
,
LoadBalanceRequest
:
loadBalanceSegment
,
rootCoord
:
qc
.
rootCoordClient
,
dataCoord
:
qc
.
dataCoordClient
,
cluster
:
qc
.
cluster
,
meta
:
qc
.
meta
,
}
qc
.
scheduler
.
Enqueue
([]
task
{
loadBalanceTask
})
//TODO::deal enqueue error
qc
.
scheduler
.
Enqueue
(
loadBalanceTask
)
log
.
Debug
(
"start a loadBalance task"
,
zap
.
Any
(
"task"
,
loadBalanceTask
))
}
...
...
@@ -271,21 +271,19 @@ func (qc *QueryCoord) watchNodeLoop() {
BalanceReason
:
querypb
.
TriggerCondition_nodeDown
,
}
baseTask
:=
newBaseTask
(
qc
.
loopCtx
,
querypb
.
TriggerCondition_nodeDown
)
loadBalanceTask
:=
&
LoadBalanceTask
{
BaseTask
:
BaseTask
{
ctx
:
qc
.
loopCtx
,
Condition
:
NewTaskCondition
(
qc
.
loopCtx
),
triggerCondition
:
querypb
.
TriggerCondition_nodeDown
,
},
BaseTask
:
baseTask
,
LoadBalanceRequest
:
loadBalanceSegment
,
rootCoord
:
qc
.
rootCoordClient
,
dataCoord
:
qc
.
dataCoordClient
,
cluster
:
qc
.
cluster
,
meta
:
qc
.
meta
,
}
qc
.
scheduler
.
Enqueue
([]
task
{
loadBalanceTask
})
log
.
Debug
(
"start a loadBalance task"
,
zap
.
Any
(
"task"
,
loadBalanceTask
))
qc
.
metricsCacheManager
.
InvalidateSystemInfoMetrics
()
//TODO:: deal enqueue error
qc
.
scheduler
.
Enqueue
(
loadBalanceTask
)
log
.
Debug
(
"start a loadBalance task"
,
zap
.
Any
(
"task"
,
loadBalanceTask
))
}
}
}
...
...
internal/querycoord/query_coord_test.go
浏览文件 @
235d736a
...
...
@@ -93,6 +93,11 @@ func startQueryCoord(ctx context.Context) (*QueryCoord, error) {
return
coord
,
nil
}
func
createDefaultPartition
(
ctx
context
.
Context
,
queryCoord
*
QueryCoord
)
error
{
_
,
err
:=
queryCoord
.
rootCoordClient
.
CreatePartition
(
ctx
,
nil
)
return
err
}
func
startUnHealthyQueryCoord
(
ctx
context
.
Context
)
(
*
QueryCoord
,
error
)
{
factory
:=
msgstream
.
NewPmsFactory
()
...
...
internal/querycoord/task.go
浏览文件 @
235d736a
此差异已折叠。
点击以展开。
internal/querycoord/task_scheduler.go
浏览文件 @
235d736a
此差异已折叠。
点击以展开。
internal/querycoord/task_scheduler_test.go
浏览文件 @
235d736a
...
...
@@ -49,6 +49,7 @@ func (tt *testTask) Timestamp() Timestamp {
}
func
(
tt
*
testTask
)
PreExecute
(
ctx
context
.
Context
)
error
{
tt
.
SetResultInfo
(
nil
)
log
.
Debug
(
"test task preExecute..."
)
return
nil
}
...
...
@@ -59,7 +60,7 @@ func (tt *testTask) Execute(ctx context.Context) error {
switch
tt
.
baseMsg
.
MsgType
{
case
commonpb
.
MsgType_LoadSegments
:
childTask
:=
&
LoadSegmentTask
{
BaseTask
:
BaseTask
{
BaseTask
:
&
BaseTask
{
ctx
:
tt
.
ctx
,
Condition
:
NewTaskCondition
(
tt
.
ctx
),
triggerCondition
:
tt
.
triggerCondition
,
...
...
@@ -70,13 +71,14 @@ func (tt *testTask) Execute(ctx context.Context) error {
},
NodeID
:
tt
.
nodeID
,
},
meta
:
tt
.
meta
,
cluster
:
tt
.
cluster
,
meta
:
tt
.
meta
,
cluster
:
tt
.
cluster
,
excludeNodeIDs
:
[]
int64
{},
}
tt
.
AddChildTask
(
childTask
)
case
commonpb
.
MsgType_WatchDmChannels
:
childTask
:=
&
WatchDmChannelTask
{
BaseTask
:
BaseTask
{
BaseTask
:
&
BaseTask
{
ctx
:
tt
.
ctx
,
Condition
:
NewTaskCondition
(
tt
.
ctx
),
triggerCondition
:
tt
.
triggerCondition
,
...
...
@@ -87,13 +89,14 @@ func (tt *testTask) Execute(ctx context.Context) error {
},
NodeID
:
tt
.
nodeID
,
},
cluster
:
tt
.
cluster
,
meta
:
tt
.
meta
,
cluster
:
tt
.
cluster
,
meta
:
tt
.
meta
,
excludeNodeIDs
:
[]
int64
{},
}
tt
.
AddChildTask
(
childTask
)
case
commonpb
.
MsgType_WatchQueryChannels
:
childTask
:=
&
WatchQueryChannelTask
{
BaseTask
:
BaseTask
{
BaseTask
:
&
BaseTask
{
ctx
:
tt
.
ctx
,
Condition
:
NewTaskCondition
(
tt
.
ctx
),
triggerCondition
:
tt
.
triggerCondition
,
...
...
@@ -129,12 +132,7 @@ func TestWatchQueryChannel_ClearEtcdInfoAfterAssignedNodeDown(t *testing.T) {
queryNode
.
addQueryChannels
=
returnFailedResult
nodeID
:=
queryNode
.
queryNodeID
for
{
_
,
err
=
queryCoord
.
cluster
.
getNodeByID
(
nodeID
)
if
err
==
nil
{
break
}
}
waitQueryNodeOnline
(
queryCoord
.
cluster
,
nodeID
)
testTask
:=
&
testTask
{
BaseTask
:
BaseTask
{
ctx
:
baseCtx
,
...
...
@@ -148,7 +146,7 @@ func TestWatchQueryChannel_ClearEtcdInfoAfterAssignedNodeDown(t *testing.T) {
meta
:
queryCoord
.
meta
,
nodeID
:
nodeID
,
}
queryCoord
.
scheduler
.
Enqueue
(
[]
task
{
testTask
}
)
queryCoord
.
scheduler
.
Enqueue
(
testTask
)
queryNode
.
stop
()
err
=
removeNodeSession
(
queryNode
.
queryNodeID
)
...
...
@@ -169,7 +167,11 @@ func TestUnMarshalTask(t *testing.T) {
refreshParams
()
kv
,
err
:=
etcdkv
.
NewEtcdKV
(
Params
.
EtcdEndpoints
,
Params
.
MetaRootPath
)
assert
.
Nil
(
t
,
err
)
taskScheduler
:=
&
TaskScheduler
{}
baseCtx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
taskScheduler
:=
&
TaskScheduler
{
ctx
:
baseCtx
,
cancel
:
cancel
,
}
t
.
Run
(
"Test LoadCollectionTask"
,
func
(
t
*
testing
.
T
)
{
loadTask
:=
&
LoadCollectionTask
{
...
...
@@ -187,7 +189,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalLoadCollection"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1000
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_LoadCollection
)
})
...
...
@@ -208,7 +210,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalLoadPartition"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1001
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_LoadPartitions
)
})
...
...
@@ -229,7 +231,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalReleaseCollection"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1002
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_ReleaseCollection
)
})
...
...
@@ -250,7 +252,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalReleasePartition"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1003
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_ReleasePartitions
)
})
...
...
@@ -271,7 +273,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalLoadSegment"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1004
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_LoadSegments
)
})
...
...
@@ -292,7 +294,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalReleaseSegment"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1005
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_ReleaseSegments
)
})
...
...
@@ -313,7 +315,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalWatchDmChannel"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1006
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_WatchDmChannels
)
})
...
...
@@ -334,7 +336,7 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalWatchQueryChannel"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1007
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_WatchQueryChannels
)
})
...
...
@@ -356,17 +358,22 @@ func TestUnMarshalTask(t *testing.T) {
value
,
err
:=
kv
.
Load
(
"testMarshalLoadBalanceTask"
)
assert
.
Nil
(
t
,
err
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
value
)
task
,
err
:=
taskScheduler
.
unmarshalTask
(
1008
,
value
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
task
.
Type
(),
commonpb
.
MsgType_LoadBalanceSegments
)
})
taskScheduler
.
Close
()
}
func
TestReloadTaskFromKV
(
t
*
testing
.
T
)
{
refreshParams
()
kv
,
err
:=
etcdkv
.
NewEtcdKV
(
Params
.
EtcdEndpoints
,
Params
.
MetaRootPath
)
assert
.
Nil
(
t
,
err
)
baseCtx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
taskScheduler
:=
&
TaskScheduler
{
ctx
:
baseCtx
,
cancel
:
cancel
,
client
:
kv
,
triggerTaskQueue
:
NewTaskQueue
(),
}
...
...
internal/querycoord/task_test.go
浏览文件 @
235d736a
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录