Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
5edbb826
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 搜索 >>
未验证
提交
5edbb826
编写于
11月 16, 2021
作者:
C
congqixia
提交者:
GitHub
11月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add session revoke (#11908)
Signed-off-by:
N
Congqi Xia
<
congqi.xia@zilliz.com
>
上级
7908045a
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
64 addition
and
2 deletion
+64
-2
internal/datacoord/server.go
internal/datacoord/server.go
+1
-0
internal/datanode/data_node.go
internal/datanode/data_node.go
+2
-0
internal/indexcoord/index_coord.go
internal/indexcoord/index_coord.go
+1
-0
internal/indexnode/indexnode.go
internal/indexnode/indexnode.go
+1
-0
internal/proxy/proxy.go
internal/proxy/proxy.go
+2
-0
internal/querycoord/query_coord.go
internal/querycoord/query_coord.go
+1
-0
internal/querynode/query_node.go
internal/querynode/query_node.go
+1
-0
internal/rootcoord/root_coord.go
internal/rootcoord/root_coord.go
+2
-0
internal/util/sessionutil/session_util.go
internal/util/sessionutil/session_util.go
+17
-2
internal/util/sessionutil/session_util_test.go
internal/util/sessionutil/session_util_test.go
+36
-0
未找到文件。
internal/datacoord/server.go
浏览文件 @
5edbb826
...
...
@@ -711,6 +711,7 @@ func (s *Server) Stop() error {
s
.
cluster
.
Close
()
s
.
garbageCollector
.
close
()
s
.
stopServerLoop
()
s
.
session
.
Revoke
(
time
.
Second
)
if
Params
.
EnableCompaction
{
s
.
stopCompactionTrigger
()
...
...
internal/datanode/data_node.go
浏览文件 @
5edbb826
...
...
@@ -639,6 +639,8 @@ func (node *DataNode) Stop() error {
return
err
}
}
node
.
session
.
Revoke
(
time
.
Second
)
return
nil
}
...
...
internal/indexcoord/index_coord.go
浏览文件 @
5edbb826
...
...
@@ -285,6 +285,7 @@ func (i *IndexCoord) Stop() error {
for
_
,
cb
:=
range
i
.
closeCallbacks
{
cb
()
}
i
.
session
.
Revoke
(
time
.
Second
)
return
nil
}
...
...
internal/indexnode/indexnode.go
浏览文件 @
5edbb826
...
...
@@ -217,6 +217,7 @@ func (i *IndexNode) Stop() error {
for
_
,
cb
:=
range
i
.
closeCallbacks
{
cb
()
}
i
.
session
.
Revoke
(
time
.
Second
)
log
.
Debug
(
"Index node stopped."
)
return
nil
}
...
...
internal/proxy/proxy.go
浏览文件 @
5edbb826
...
...
@@ -367,6 +367,8 @@ func (node *Proxy) Stop() error {
cb
()
}
node
.
session
.
Revoke
(
time
.
Second
)
return
nil
}
...
...
internal/querycoord/query_coord.go
浏览文件 @
5edbb826
...
...
@@ -208,6 +208,7 @@ func (qc *QueryCoord) Stop() error {
qc
.
UpdateStateCode
(
internalpb
.
StateCode_Abnormal
)
qc
.
loopWg
.
Wait
()
qc
.
session
.
Revoke
(
time
.
Second
)
return
nil
}
...
...
internal/querynode/query_node.go
浏览文件 @
5edbb826
...
...
@@ -298,6 +298,7 @@ func (node *QueryNode) Stop() error {
if
node
.
statsService
!=
nil
{
node
.
statsService
.
close
()
}
node
.
session
.
Revoke
(
time
.
Second
)
return
nil
}
...
...
internal/rootcoord/root_coord.go
浏览文件 @
5edbb826
...
...
@@ -1170,6 +1170,8 @@ func (c *Core) Stop() error {
c
.
cancel
()
c
.
wg
.
Wait
()
c
.
stateCode
.
Store
(
internalpb
.
StateCode_Abnormal
)
// wait at most one second to revoke
c
.
session
.
Revoke
(
time
.
Second
)
return
nil
}
...
...
internal/util/sessionutil/session_util.go
浏览文件 @
5edbb826
...
...
@@ -55,7 +55,7 @@ type Session struct {
liveCh
<-
chan
bool
etcdCli
*
clientv3
.
Client
leaseID
clientv3
.
LeaseID
leaseID
*
clientv3
.
LeaseID
metaRoot
string
}
...
...
@@ -189,7 +189,7 @@ func (s *Session) registerService() (<-chan *clientv3.LeaseKeepAliveResponse, er
log
.
Error
(
"register service"
,
zap
.
Error
(
err
))
return
err
}
s
.
leaseID
=
resp
.
ID
s
.
leaseID
=
&
resp
.
ID
sessionJSON
,
err
:=
json
.
Marshal
(
s
)
if
err
!=
nil
{
...
...
@@ -388,3 +388,18 @@ func (s *Session) LivenessCheck(ctx context.Context, callback func()) {
}
}
}
// Revoke revokes the internal leaseID for the session key
func
(
s
*
Session
)
Revoke
(
timeout
time
.
Duration
)
{
if
s
==
nil
{
return
}
if
s
.
etcdCli
==
nil
||
s
.
leaseID
==
nil
{
return
}
// can NOT use s.ctx, it may be Done here
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
// ignores resp & error, just do best effort to revoke
_
,
_
=
s
.
etcdCli
.
Revoke
(
ctx
,
*
s
.
leaseID
)
}
internal/util/sessionutil/session_util_test.go
浏览文件 @
5edbb826
...
...
@@ -202,3 +202,39 @@ func TestSessionLivenessCheck(t *testing.T) {
assert
.
False
(
t
,
flag
)
}
func
TestSessionRevoke
(
t
*
testing
.
T
)
{
s
:=
&
Session
{}
assert
.
NotPanics
(
t
,
func
()
{
s
.
Revoke
(
time
.
Second
)
})
s
=
(
*
Session
)(
nil
)
assert
.
NotPanics
(
t
,
func
()
{
s
.
Revoke
(
time
.
Second
)
})
ctx
:=
context
.
Background
()
Params
.
Init
()
endpoints
,
err
:=
Params
.
Load
(
"_EtcdEndpoints"
)
if
err
!=
nil
{
panic
(
err
)
}
metaRoot
:=
fmt
.
Sprintf
(
"%d/%s"
,
rand
.
Int
(),
DefaultServiceRoot
)
etcdEndpoints
:=
strings
.
Split
(
endpoints
,
","
)
etcdKV
,
err
:=
etcdkv
.
NewEtcdKV
(
etcdEndpoints
,
metaRoot
)
assert
.
NoError
(
t
,
err
)
err
=
etcdKV
.
RemoveWithPrefix
(
""
)
assert
.
NoError
(
t
,
err
)
defer
etcdKV
.
Close
()
defer
etcdKV
.
RemoveWithPrefix
(
""
)
s
=
NewSession
(
ctx
,
metaRoot
,
etcdEndpoints
)
s
.
Init
(
"revoketest"
,
"testAddr"
,
false
)
assert
.
NotPanics
(
t
,
func
()
{
s
.
Revoke
(
time
.
Second
)
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录