Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
ef96b40d
M
milvus
项目概览
milvus
/
milvus
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
ef96b40d
编写于
12月 22, 2021
作者:
X
xige-16
提交者:
GitHub
12月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete useless watchGlobalSegmentMeta (#13914)
Signed-off-by:
N
xige-16
<
xi.ge@zilliz.com
>
上级
dfe06841
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
0 addition
and
129 deletion
+0
-129
internal/querynode/historical.go
internal/querynode/historical.go
+0
-57
internal/querynode/historical_test.go
internal/querynode/historical_test.go
+0
-72
未找到文件。
internal/querynode/historical.go
浏览文件 @
ef96b40d
...
...
@@ -20,20 +20,15 @@ import (
"context"
"errors"
"fmt"
"path/filepath"
"strconv"
"sync"
"github.com/golang/protobuf/proto"
etcdkv
"github.com/milvus-io/milvus/internal/kv/etcd"
"go.etcd.io/etcd/api/v3/mvccpb"
"go.uber.org/zap"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/proto/segcorepb"
"github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/internal/util"
)
// historical is in charge of historical data in query node
...
...
@@ -65,7 +60,6 @@ func newHistorical(ctx context.Context,
}
func
(
h
*
historical
)
start
()
{
go
h
.
watchGlobalSegmentMeta
()
}
// close would release all resources in historical
...
...
@@ -74,57 +68,6 @@ func (h *historical) close() {
h
.
replica
.
freeAll
()
}
func
(
h
*
historical
)
watchGlobalSegmentMeta
()
{
log
.
Debug
(
"query node watchGlobalSegmentMeta start"
)
watchChan
:=
h
.
etcdKV
.
WatchWithPrefix
(
util
.
SegmentMetaPrefix
)
for
{
select
{
case
<-
h
.
ctx
.
Done
()
:
log
.
Debug
(
"query node watchGlobalSegmentMeta close"
)
return
case
resp
:=
<-
watchChan
:
for
_
,
event
:=
range
resp
.
Events
{
segmentID
,
err
:=
strconv
.
ParseInt
(
filepath
.
Base
(
string
(
event
.
Kv
.
Key
)),
10
,
64
)
if
err
!=
nil
{
log
.
Warn
(
"watchGlobalSegmentMeta failed"
,
zap
.
Any
(
"error"
,
err
.
Error
()))
continue
}
switch
event
.
Type
{
case
mvccpb
.
PUT
:
log
.
Debug
(
"globalSealedSegments add segment"
,
zap
.
Any
(
"segmentID"
,
segmentID
),
)
segmentInfo
:=
&
querypb
.
SegmentInfo
{}
err
=
proto
.
Unmarshal
(
event
.
Kv
.
Value
,
segmentInfo
)
if
err
!=
nil
{
log
.
Warn
(
"watchGlobalSegmentMeta failed"
,
zap
.
Any
(
"error"
,
err
.
Error
()))
continue
}
h
.
addGlobalSegmentInfo
(
segmentID
,
segmentInfo
)
case
mvccpb
.
DELETE
:
log
.
Debug
(
"globalSealedSegments delete segment"
,
zap
.
Any
(
"segmentID"
,
segmentID
),
)
h
.
removeGlobalSegmentInfo
(
segmentID
)
}
}
}
}
}
func
(
h
*
historical
)
addGlobalSegmentInfo
(
segmentID
UniqueID
,
segmentInfo
*
querypb
.
SegmentInfo
)
{
h
.
mu
.
Lock
()
defer
h
.
mu
.
Unlock
()
h
.
globalSealedSegments
[
segmentID
]
=
segmentInfo
}
func
(
h
*
historical
)
removeGlobalSegmentInfo
(
segmentID
UniqueID
)
{
h
.
mu
.
Lock
()
defer
h
.
mu
.
Unlock
()
delete
(
h
.
globalSealedSegments
,
segmentID
)
}
func
(
h
*
historical
)
getGlobalSegmentIDsByCollectionID
(
collectionID
UniqueID
)
[]
UniqueID
{
h
.
mu
.
Lock
()
defer
h
.
mu
.
Unlock
()
...
...
internal/querynode/historical_test.go
浏览文件 @
ef96b40d
...
...
@@ -18,83 +18,11 @@ package querynode
import
(
"context"
"strconv"
"testing"
"time"
"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/util"
"github.com/stretchr/testify/assert"
)
func
TestHistorical_GlobalSealedSegments
(
t
*
testing
.
T
)
{
n
:=
newQueryNodeMock
()
// init meta
segmentID
:=
UniqueID
(
0
)
partitionID
:=
UniqueID
(
1
)
collectionID
:=
UniqueID
(
2
)
segmentInfo
:=
&
querypb
.
SegmentInfo
{
SegmentID
:
segmentID
,
CollectionID
:
collectionID
,
PartitionID
:
partitionID
,
}
emptySegmentCheck
:=
func
()
{
segmentIDs
:=
n
.
historical
.
getGlobalSegmentIDsByCollectionID
(
collectionID
)
assert
.
Equal
(
t
,
0
,
len
(
segmentIDs
))
segmentIDs
=
n
.
historical
.
getGlobalSegmentIDsByPartitionIds
([]
UniqueID
{
partitionID
})
assert
.
Equal
(
t
,
0
,
len
(
segmentIDs
))
}
// static test
emptySegmentCheck
()
n
.
historical
.
addGlobalSegmentInfo
(
segmentID
,
segmentInfo
)
segmentIDs
:=
n
.
historical
.
getGlobalSegmentIDsByCollectionID
(
collectionID
)
assert
.
Equal
(
t
,
1
,
len
(
segmentIDs
))
assert
.
Equal
(
t
,
segmentIDs
[
0
],
segmentID
)
segmentIDs
=
n
.
historical
.
getGlobalSegmentIDsByPartitionIds
([]
UniqueID
{
partitionID
})
assert
.
Equal
(
t
,
1
,
len
(
segmentIDs
))
assert
.
Equal
(
t
,
segmentIDs
[
0
],
segmentID
)
n
.
historical
.
removeGlobalSegmentInfo
(
segmentID
)
emptySegmentCheck
()
n
.
historical
.
addGlobalSegmentInfo
(
segmentID
,
segmentInfo
)
n
.
historical
.
removeGlobalSegmentIDsByCollectionID
(
collectionID
)
emptySegmentCheck
()
n
.
historical
.
addGlobalSegmentInfo
(
segmentID
,
segmentInfo
)
n
.
historical
.
removeGlobalSegmentIDsByPartitionIds
([]
UniqueID
{
partitionID
})
emptySegmentCheck
()
// watch test
go
n
.
historical
.
watchGlobalSegmentMeta
()
time
.
Sleep
(
100
*
time
.
Millisecond
)
// for etcd latency
segmentInfoBytes
,
err
:=
proto
.
Marshal
(
segmentInfo
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
n
.
etcdKV
)
segmentKey
:=
util
.
SegmentMetaPrefix
+
"/"
+
strconv
.
FormatInt
(
segmentID
,
10
)
err
=
n
.
etcdKV
.
Save
(
segmentKey
,
string
(
segmentInfoBytes
))
assert
.
NoError
(
t
,
err
)
time
.
Sleep
(
200
*
time
.
Millisecond
)
// for etcd latency
segmentIDs
=
n
.
historical
.
getGlobalSegmentIDsByCollectionID
(
collectionID
)
assert
.
Equal
(
t
,
1
,
len
(
segmentIDs
))
assert
.
Equal
(
t
,
segmentIDs
[
0
],
segmentID
)
segmentIDs
=
n
.
historical
.
getGlobalSegmentIDsByPartitionIds
([]
UniqueID
{
partitionID
})
assert
.
Equal
(
t
,
1
,
len
(
segmentIDs
))
assert
.
Equal
(
t
,
segmentIDs
[
0
],
segmentID
)
err
=
n
.
etcdKV
.
Remove
(
segmentKey
)
assert
.
NoError
(
t
,
err
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
// for etcd latency
emptySegmentCheck
()
}
func
TestHistorical_Search
(
t
*
testing
.
T
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录