Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
d374ea71
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,发现更多精彩内容 >>
未验证
提交
d374ea71
编写于
9月 28, 2021
作者:
C
congqixia
提交者:
GitHub
9月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify liveness check in datacoord and datanode (#8480)
Signed-off-by:
N
Congqi Xia
<
congqi.xia@zilliz.com
>
上级
7df90e0e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
73 deletion
+14
-73
internal/datacoord/server.go
internal/datacoord/server.go
+8
-26
internal/datanode/data_node.go
internal/datanode/data_node.go
+6
-22
internal/datanode/data_node_test.go
internal/datanode/data_node_test.go
+0
-25
未找到文件。
internal/datacoord/server.go
浏览文件 @
d374ea71
...
...
@@ -98,9 +98,9 @@ type Server struct {
flushCh
chan
UniqueID
msFactory
msgstream
.
Factory
session
*
sessionutil
.
Session
activeCh
<-
chan
bool
eventCh
<-
chan
*
sessionutil
.
SessionEvent
session
*
sessionutil
.
Session
liveCh
<-
chan
bool
eventCh
<-
chan
*
sessionutil
.
SessionEvent
dataNodeCreator
DataNodeCreatorFunc
rootCoordClientCreator
RootCoordCreatorFunc
...
...
@@ -183,7 +183,7 @@ func (s *Server) Register() error {
if
s
.
session
==
nil
{
return
errors
.
New
(
"failed to initialize session"
)
}
s
.
act
iveCh
=
s
.
session
.
Init
(
typeutil
.
DataCoordRole
,
Params
.
IP
,
true
)
s
.
l
iveCh
=
s
.
session
.
Init
(
typeutil
.
DataCoordRole
,
Params
.
IP
,
true
)
Params
.
NodeID
=
s
.
session
.
ServerID
return
nil
}
...
...
@@ -304,12 +304,14 @@ func (s *Server) initMeta() error {
func
(
s
*
Server
)
startServerLoop
()
{
s
.
serverLoopCtx
,
s
.
serverLoopCancel
=
context
.
WithCancel
(
s
.
ctx
)
s
.
serverLoopWg
.
Add
(
5
)
s
.
serverLoopWg
.
Add
(
4
)
go
s
.
startStatsChannel
(
s
.
serverLoopCtx
)
go
s
.
startDataNodeTtLoop
(
s
.
serverLoopCtx
)
go
s
.
startWatchService
(
s
.
serverLoopCtx
)
go
s
.
startActiveCheck
(
s
.
serverLoopCtx
)
go
s
.
startFlushLoop
(
s
.
serverLoopCtx
)
go
s
.
session
.
LivenessCheck
(
s
.
serverLoopCtx
,
s
.
liveCh
,
func
()
{
s
.
Stop
()
})
}
func
(
s
*
Server
)
startStatsChannel
(
ctx
context
.
Context
)
{
...
...
@@ -469,26 +471,6 @@ func (s *Server) handleSessionEvent(ctx context.Context, event *sessionutil.Sess
}
}
func
(
s
*
Server
)
startActiveCheck
(
ctx
context
.
Context
)
{
defer
logutil
.
LogPanic
()
defer
s
.
serverLoopWg
.
Done
()
for
{
select
{
case
_
,
ok
:=
<-
s
.
activeCh
:
if
ok
{
continue
}
go
func
()
{
s
.
Stop
()
}()
log
.
Debug
(
"disconnect with etcd and shutdown data coordinator"
)
return
case
<-
ctx
.
Done
()
:
log
.
Debug
(
"connection check shutdown"
)
return
}
}
}
func
(
s
*
Server
)
startFlushLoop
(
ctx
context
.
Context
)
{
defer
logutil
.
LogPanic
()
defer
s
.
serverLoopWg
.
Done
()
...
...
internal/datanode/data_node.go
浏览文件 @
d374ea71
...
...
@@ -95,6 +95,7 @@ type DataNode struct {
dataCoord
types
.
DataCoord
session
*
sessionutil
.
Session
liveCh
<-
chan
bool
kvClient
*
etcdkv
.
EtcdKV
closer
io
.
Closer
...
...
@@ -149,8 +150,7 @@ func (node *DataNode) SetDataCoordInterface(ds types.DataCoord) error {
// Register register datanode to etcd
func
(
node
*
DataNode
)
Register
()
error
{
node
.
session
=
sessionutil
.
NewSession
(
node
.
ctx
,
Params
.
MetaRootPath
,
Params
.
EtcdEndpoints
)
activeCh
:=
node
.
session
.
Init
(
typeutil
.
DataNodeRole
,
Params
.
IP
+
":"
+
strconv
.
Itoa
(
Params
.
Port
),
false
)
go
node
.
etcdAliveCheck
(
node
.
ctx
,
activeCh
)
node
.
liveCh
=
node
.
session
.
Init
(
typeutil
.
DataNodeRole
,
Params
.
IP
+
":"
+
strconv
.
Itoa
(
Params
.
Port
),
false
)
Params
.
NodeID
=
node
.
session
.
ServerID
node
.
NodeID
=
node
.
session
.
ServerID
// Start node watch node
...
...
@@ -202,26 +202,6 @@ func (node *DataNode) StartWatchChannels(ctx context.Context) {
}
}
// etcdAliveCheck performs alive check for etcd connection
// will close datanode if check fails
func
(
node
*
DataNode
)
etcdAliveCheck
(
ctx
context
.
Context
,
ch
<-
chan
bool
)
{
for
{
select
{
case
_
,
ok
:=
<-
ch
:
if
ok
{
// ok means still alive do nothing
continue
}
// not ok, disconnect
go
func
()
{
node
.
Stop
()
}()
log
.
Warn
(
"disconnected from etcd, shuting down datanode"
,
zap
.
Int64
(
"ServerID"
,
node
.
NodeID
))
return
case
<-
ctx
.
Done
()
:
log
.
Warn
(
"etcd alive check quit, due to ctx done"
)
return
}
}
}
// handleChannelEvt handles event from kv watch event
func
(
node
*
DataNode
)
handleChannelEvt
(
evt
*
clientv3
.
Event
)
{
switch
evt
.
Type
{
...
...
@@ -368,6 +348,10 @@ func (node *DataNode) Start() error {
go
node
.
BackGroundGC
(
node
.
clearSignal
)
go
node
.
session
.
LivenessCheck
(
node
.
ctx
,
node
.
liveCh
,
func
()
{
node
.
Stop
()
})
Params
.
CreatedTime
=
time
.
Now
()
Params
.
UpdatedTime
=
time
.
Now
()
...
...
internal/datanode/data_node_test.go
浏览文件 @
d374ea71
...
...
@@ -449,31 +449,6 @@ func TestDataNode(t *testing.T) {
node
.
Stop
()
}
func
TestDataNodeEtcdAlive
(
t
*
testing
.
T
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
node
:=
newIDLEDataNodeMock
(
ctx
)
node
.
Init
()
node
.
Start
()
mockCh
:=
make
(
chan
bool
)
go
node
.
etcdAliveCheck
(
ctx
,
mockCh
)
mockCh
<-
true
flag
:=
false
select
{
case
<-
node
.
ctx
.
Done
()
:
flag
=
true
default
:
}
assert
.
False
(
t
,
flag
)
close
(
mockCh
)
_
,
ok
:=
<-
node
.
ctx
.
Done
()
assert
.
False
(
t
,
ok
)
}
func
TestWatchChannel
(
t
*
testing
.
T
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
node
:=
newIDLEDataNodeMock
(
ctx
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录