Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
08fd28b3
M
milvus
项目概览
milvus
/
milvus
8 个月 前同步成功
通知
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 搜索 >>
未验证
提交
08fd28b3
编写于
8月 21, 2023
作者:
X
XuanYang-cn
提交者:
GitHub
8月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Only do gracefully stop when DN Stop (#26399)
Signed-off-by:
N
yangxuan
<
xuan.yang@zilliz.com
>
上级
e69e200f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
72 addition
and
23 deletion
+72
-23
internal/datanode/data_sync_service.go
internal/datanode/data_sync_service.go
+8
-0
internal/datanode/data_sync_service_test.go
internal/datanode/data_sync_service_test.go
+2
-2
internal/datanode/flow_graph_dmstream_input_node.go
internal/datanode/flow_graph_dmstream_input_node.go
+10
-2
internal/datanode/flow_graph_manager.go
internal/datanode/flow_graph_manager.go
+1
-1
internal/util/flowgraph/flow_graph.go
internal/util/flowgraph/flow_graph.go
+17
-6
internal/util/flowgraph/input_node.go
internal/util/flowgraph/input_node.go
+34
-12
未找到文件。
internal/datanode/data_sync_service.go
浏览文件 @
08fd28b3
...
...
@@ -161,6 +161,14 @@ func (dsService *dataSyncService) start() {
}
}
func
(
dsService
*
dataSyncService
)
GracefullyClose
()
{
if
dsService
.
fg
!=
nil
{
log
.
Info
(
"dataSyncService gracefully closing flowgraph"
)
dsService
.
fg
.
SetCloseMethod
(
flowgraph
.
CloseGracefully
)
dsService
.
close
()
}
}
func
(
dsService
*
dataSyncService
)
close
()
{
dsService
.
stopOnce
.
Do
(
func
()
{
log
:=
log
.
Ctx
(
context
.
Background
())
.
With
(
...
...
internal/datanode/data_sync_service_test.go
浏览文件 @
08fd28b3
...
...
@@ -534,7 +534,7 @@ func TestDataSyncService_Close(t *testing.T) {
assert
.
Equal
(
t
,
0
,
len
(
syncService
.
flushListener
))
// close will trigger a force sync
syncService
.
c
lose
()
syncService
.
GracefullyC
lose
()
assert
.
Eventually
(
t
,
func
()
bool
{
return
len
(
syncService
.
flushListener
)
==
1
},
5
*
time
.
Second
,
100
*
time
.
Millisecond
)
flushPack
,
ok
:=
<-
syncService
.
flushListener
...
...
@@ -547,7 +547,7 @@ func TestDataSyncService_Close(t *testing.T) {
<-
syncService
.
ctx
.
Done
()
// Double close is safe
syncService
.
c
lose
()
syncService
.
GracefullyC
lose
()
<-
syncService
.
ctx
.
Done
()
}
...
...
internal/datanode/flow_graph_dmstream_input_node.go
浏览文件 @
08fd28b3
...
...
@@ -62,7 +62,15 @@ func newDmInputNode(dispatcherClient msgdispatcher.Client, seekPos *msgpb.MsgPos
}
name
:=
fmt
.
Sprintf
(
"dmInputNode-data-%d-%s"
,
dmNodeConfig
.
collectionID
,
dmNodeConfig
.
vChannelName
)
node
:=
flowgraph
.
NewInputNode
(
input
,
name
,
dmNodeConfig
.
maxQueueLength
,
dmNodeConfig
.
maxParallelism
,
typeutil
.
DataNodeRole
,
paramtable
.
GetNodeID
(),
dmNodeConfig
.
collectionID
,
metrics
.
AllLabel
)
node
:=
flowgraph
.
NewInputNode
(
input
,
name
,
dmNodeConfig
.
maxQueueLength
,
dmNodeConfig
.
maxParallelism
,
typeutil
.
DataNodeRole
,
paramtable
.
GetNodeID
(),
dmNodeConfig
.
collectionID
,
metrics
.
AllLabel
,
)
return
node
,
nil
}
internal/datanode/flow_graph_manager.go
浏览文件 @
08fd28b3
...
...
@@ -216,7 +216,7 @@ func (fm *flowgraphManager) getFlowGraphNum() int {
func
(
fm
*
flowgraphManager
)
dropAll
()
{
log
.
Info
(
"start drop all flowgraph resources in DataNode"
)
fm
.
flowgraphs
.
Range
(
func
(
key
string
,
value
*
dataSyncService
)
bool
{
value
.
c
lose
()
value
.
GracefullyC
lose
()
fm
.
flowgraphs
.
GetAndRemove
(
key
)
log
.
Info
(
"successfully dropped flowgraph"
,
zap
.
String
(
"vChannelName"
,
key
))
...
...
internal/util/flowgraph/flow_graph.go
浏览文件 @
08fd28b3
...
...
@@ -21,16 +21,18 @@ import (
"sync"
"github.com/cockroachdb/errors"
"go.uber.org/atomic"
)
// Flow Graph is no longer a graph rather than a simple pipeline, this simplified our code and increase recovery speed - xiaofan.
// TimeTickedFlowGraph flowgraph with input from tt msg stream
type
TimeTickedFlowGraph
struct
{
nodeCtx
map
[
NodeName
]
*
nodeCtx
stopOnce
sync
.
Once
startOnce
sync
.
Once
closeWg
*
sync
.
WaitGroup
nodeCtx
map
[
NodeName
]
*
nodeCtx
stopOnce
sync
.
Once
startOnce
sync
.
Once
closeWg
*
sync
.
WaitGroup
closeGracefully
*
atomic
.
Bool
}
// AddNode add Node into flowgraph
...
...
@@ -93,6 +95,14 @@ func (fg *TimeTickedFlowGraph) Unblock() {
}
}
func
(
fg
*
TimeTickedFlowGraph
)
SetCloseMethod
(
gracefully
bool
)
{
for
_
,
v
:=
range
fg
.
nodeCtx
{
if
v
.
node
.
IsInputNode
()
{
v
.
node
.
(
*
InputNode
)
.
SetCloseMethod
(
gracefully
)
}
}
}
// Close closes all nodes in flowgraph
func
(
fg
*
TimeTickedFlowGraph
)
Close
()
{
fg
.
stopOnce
.
Do
(
func
()
{
...
...
@@ -108,8 +118,9 @@ func (fg *TimeTickedFlowGraph) Close() {
// NewTimeTickedFlowGraph create timetick flowgraph
func
NewTimeTickedFlowGraph
(
ctx
context
.
Context
)
*
TimeTickedFlowGraph
{
flowGraph
:=
TimeTickedFlowGraph
{
nodeCtx
:
make
(
map
[
string
]
*
nodeCtx
),
closeWg
:
&
sync
.
WaitGroup
{},
nodeCtx
:
make
(
map
[
string
]
*
nodeCtx
),
closeWg
:
&
sync
.
WaitGroup
{},
closeGracefully
:
atomic
.
NewBool
(
CloseImmediately
),
}
return
&
flowGraph
...
...
internal/util/flowgraph/input_node.go
浏览文件 @
08fd28b3
...
...
@@ -30,9 +30,15 @@ import (
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/metrics"
"github.com/milvus-io/milvus/pkg/mq/msgstream"
"go.uber.org/atomic"
"go.uber.org/zap"
)
const
(
CloseGracefully
bool
=
true
CloseImmediately
bool
=
false
)
// InputNode is the entry point of flowgragh
type
InputNode
struct
{
BaseNode
...
...
@@ -43,7 +49,9 @@ type InputNode struct {
nodeID
int64
collectionID
int64
dataType
string
closeOnce
sync
.
Once
closeOnce
sync
.
Once
closeGracefully
*
atomic
.
Bool
}
// IsInputNode returns whether Node is InputNode
...
...
@@ -60,14 +68,27 @@ func (inNode *InputNode) Name() string {
return
inNode
.
name
}
func
(
inNode
*
InputNode
)
SetCloseMethod
(
gracefully
bool
)
{
inNode
.
closeGracefully
.
Store
(
gracefully
)
log
.
Info
(
"input node close method set"
,
zap
.
String
(
"node"
,
inNode
.
Name
()),
zap
.
Int64
(
"collection"
,
inNode
.
collectionID
),
zap
.
Any
(
"gracefully"
,
gracefully
))
}
// Operate consume a message pack from msgstream and return
func
(
inNode
*
InputNode
)
Operate
(
in
[]
Msg
)
[]
Msg
{
msgPack
,
ok
:=
<-
inNode
.
input
if
!
ok
{
log
.
Warn
(
"input closed"
,
zap
.
Any
(
"input node"
,
inNode
.
Name
()))
if
inNode
.
lastMsg
!=
nil
{
log
.
Info
(
"trigger force sync"
,
zap
.
Int64
(
"collection"
,
inNode
.
collectionID
),
log
:=
log
.
With
(
zap
.
String
(
"node"
,
inNode
.
Name
()),
zap
.
Int64
(
"collection"
,
inNode
.
collectionID
),
)
log
.
Info
(
"input node message stream closed"
,
zap
.
Bool
(
"closeGracefully"
,
inNode
.
closeGracefully
.
Load
()),
)
if
inNode
.
lastMsg
!=
nil
&&
inNode
.
closeGracefully
.
Load
()
{
log
.
Info
(
"input node trigger force sync"
,
zap
.
Any
(
"position"
,
inNode
.
lastMsg
.
EndPositions
))
return
[]
Msg
{
&
MsgStreamMsg
{
BaseMsg
:
NewBaseMsg
(
true
),
...
...
@@ -144,12 +165,13 @@ func NewInputNode(input <-chan *msgstream.MsgPack, nodeName string, maxQueueLeng
baseNode
.
SetMaxParallelism
(
maxParallelism
)
return
&
InputNode
{
BaseNode
:
baseNode
,
input
:
input
,
name
:
nodeName
,
role
:
role
,
nodeID
:
nodeID
,
collectionID
:
collectionID
,
dataType
:
dataType
,
BaseNode
:
baseNode
,
input
:
input
,
name
:
nodeName
,
role
:
role
,
nodeID
:
nodeID
,
collectionID
:
collectionID
,
dataType
:
dataType
,
closeGracefully
:
atomic
.
NewBool
(
CloseImmediately
),
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录