Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
5d2d3479
M
milvus
项目概览
milvus
/
milvus
9 个月 前同步成功
通知
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 搜索 >>
提交
5d2d3479
编写于
1月 11, 2020
作者:
れ
れいげん あらたか
提交者:
Jin Hai
1月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #651; use initialized instead of shutting_down_ (#993)
上级
fd24d6f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
30 deletion
+29
-30
core/src/db/DBImpl.cpp
core/src/db/DBImpl.cpp
+28
-29
core/src/db/DBImpl.h
core/src/db/DBImpl.h
+1
-1
未找到文件。
core/src/db/DBImpl.cpp
浏览文件 @
5d2d3479
...
...
@@ -68,7 +68,7 @@ TraverseFiles(const meta::DatePartionedTableFilesSchema& date_files, meta::Table
}
// namespace
DBImpl
::
DBImpl
(
const
DBOptions
&
options
)
:
options_
(
options
),
shutting_down_
(
tru
e
),
compact_thread_pool_
(
1
,
1
),
index_thread_pool_
(
1
,
1
)
{
:
options_
(
options
),
initialized_
(
fals
e
),
compact_thread_pool_
(
1
,
1
),
index_thread_pool_
(
1
,
1
)
{
meta_ptr_
=
MetaFactory
::
Build
(
options
.
meta_
,
options
.
mode_
);
mem_mgr_
=
MemManagerFactory
::
Build
(
meta_ptr_
,
options_
);
Start
();
...
...
@@ -83,12 +83,12 @@ DBImpl::~DBImpl() {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Status
DBImpl
::
Start
()
{
if
(
!
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
Status
::
OK
();
}
// ENGINE_LOG_TRACE << "DB service start";
shutting_down_
.
store
(
fals
e
,
std
::
memory_order_release
);
initialized_
.
store
(
tru
e
,
std
::
memory_order_release
);
// for distribute version, some nodes are read only
if
(
options_
.
mode_
!=
DBOptions
::
MODE
::
CLUSTER_READONLY
)
{
...
...
@@ -101,11 +101,10 @@ DBImpl::Start() {
Status
DBImpl
::
Stop
()
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
Status
::
OK
();
}
shutting_down_
.
store
(
true
,
std
::
memory_order_release
);
initialized_
.
store
(
false
,
std
::
memory_order_release
);
// makesure all memory data serialized
std
::
set
<
std
::
string
>
sync_table_ids
;
...
...
@@ -129,7 +128,7 @@ DBImpl::DropAll() {
Status
DBImpl
::
CreateTable
(
meta
::
TableSchema
&
table_schema
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -140,7 +139,7 @@ DBImpl::CreateTable(meta::TableSchema& table_schema) {
Status
DBImpl
::
DropTable
(
const
std
::
string
&
table_id
,
const
meta
::
DatesT
&
dates
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -149,7 +148,7 @@ DBImpl::DropTable(const std::string& table_id, const meta::DatesT& dates) {
Status
DBImpl
::
DescribeTable
(
meta
::
TableSchema
&
table_schema
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -160,7 +159,7 @@ DBImpl::DescribeTable(meta::TableSchema& table_schema) {
Status
DBImpl
::
HasTable
(
const
std
::
string
&
table_id
,
bool
&
has_or_not
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -169,7 +168,7 @@ DBImpl::HasTable(const std::string& table_id, bool& has_or_not) {
Status
DBImpl
::
AllTables
(
std
::
vector
<
meta
::
TableSchema
>&
table_schema_array
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -189,7 +188,7 @@ DBImpl::AllTables(std::vector<meta::TableSchema>& table_schema_array) {
Status
DBImpl
::
PreloadTable
(
const
std
::
string
&
table_id
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -248,7 +247,7 @@ DBImpl::PreloadTable(const std::string& table_id) {
Status
DBImpl
::
UpdateTableFlag
(
const
std
::
string
&
table_id
,
int64_t
flag
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -257,7 +256,7 @@ DBImpl::UpdateTableFlag(const std::string& table_id, int64_t flag) {
Status
DBImpl
::
GetTableRowCount
(
const
std
::
string
&
table_id
,
uint64_t
&
row_count
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -267,7 +266,7 @@ DBImpl::GetTableRowCount(const std::string& table_id, uint64_t& row_count) {
Status
DBImpl
::
CreatePartition
(
const
std
::
string
&
table_id
,
const
std
::
string
&
partition_name
,
const
std
::
string
&
partition_tag
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -276,7 +275,7 @@ DBImpl::CreatePartition(const std::string& table_id, const std::string& partitio
Status
DBImpl
::
DropPartition
(
const
std
::
string
&
partition_name
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -294,7 +293,7 @@ DBImpl::DropPartition(const std::string& partition_name) {
Status
DBImpl
::
DropPartitionByTag
(
const
std
::
string
&
table_id
,
const
std
::
string
&
partition_tag
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -310,7 +309,7 @@ DBImpl::DropPartitionByTag(const std::string& table_id, const std::string& parti
Status
DBImpl
::
ShowPartitions
(
const
std
::
string
&
table_id
,
std
::
vector
<
meta
::
TableSchema
>&
partition_schema_array
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -321,7 +320,7 @@ Status
DBImpl
::
InsertVectors
(
const
std
::
string
&
table_id
,
const
std
::
string
&
partition_tag
,
uint64_t
n
,
const
float
*
vectors
,
IDNumbers
&
vector_ids
)
{
// ENGINE_LOG_DEBUG << "Insert " << n << " vectors to cache";
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -346,7 +345,7 @@ DBImpl::InsertVectors(const std::string& table_id, const std::string& partition_
Status
DBImpl
::
CreateIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -389,7 +388,7 @@ DBImpl::CreateIndex(const std::string& table_id, const TableIndex& index) {
Status
DBImpl
::
DescribeIndex
(
const
std
::
string
&
table_id
,
TableIndex
&
index
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -398,7 +397,7 @@ DBImpl::DescribeIndex(const std::string& table_id, TableIndex& index) {
Status
DBImpl
::
DropIndex
(
const
std
::
string
&
table_id
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -410,7 +409,7 @@ Status
DBImpl
::
Query
(
const
std
::
shared_ptr
<
server
::
Context
>&
context
,
const
std
::
string
&
table_id
,
const
std
::
vector
<
std
::
string
>&
partition_tags
,
uint64_t
k
,
uint64_t
nq
,
uint64_t
nprobe
,
const
float
*
vectors
,
ResultIds
&
result_ids
,
ResultDistances
&
result_distances
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -427,7 +426,7 @@ DBImpl::Query(const std::shared_ptr<server::Context>& context, const std::string
ResultDistances
&
result_distances
)
{
auto
query_ctx
=
context
->
Child
(
"Query"
);
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -476,7 +475,7 @@ DBImpl::QueryByFileID(const std::shared_ptr<server::Context>& context, const std
ResultDistances
&
result_distances
)
{
auto
query_ctx
=
context
->
Child
(
"Query by file id"
);
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -512,7 +511,7 @@ DBImpl::QueryByFileID(const std::shared_ptr<server::Context>& context, const std
Status
DBImpl
::
Size
(
uint64_t
&
result
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
return
SHUTDOWN_ERROR
;
}
...
...
@@ -566,7 +565,7 @@ DBImpl::BackgroundTimerTask() {
Status
status
;
server
::
SystemInfo
::
GetInstance
().
Init
();
while
(
true
)
{
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
WaitMergeFileFinish
();
WaitBuildIndexFinish
();
...
...
@@ -802,7 +801,7 @@ DBImpl::BackgroundMergeFiles(const std::string& table_id) {
MergeFiles
(
table_id
,
kv
.
first
,
kv
.
second
);
status
=
ongoing_files_checker_
.
UnmarkOngoingFiles
(
files
);
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
ENGINE_LOG_DEBUG
<<
"Server will shutdown, skip merge action for table: "
<<
table_id
;
break
;
}
...
...
@@ -822,7 +821,7 @@ DBImpl::BackgroundCompaction(std::set<std::string> table_ids) {
ENGINE_LOG_ERROR
<<
"Merge files for table "
<<
table_id
<<
" failed: "
<<
status
.
ToString
();
}
if
(
shutting_down
_
.
load
(
std
::
memory_order_acquire
))
{
if
(
!
initialized
_
.
load
(
std
::
memory_order_acquire
))
{
ENGINE_LOG_DEBUG
<<
"Server will shutdown, skip merge action"
;
break
;
}
...
...
core/src/db/DBImpl.h
浏览文件 @
5d2d3479
...
...
@@ -187,7 +187,7 @@ class DBImpl : public DB {
private:
const
DBOptions
options_
;
std
::
atomic
<
bool
>
shutting_down
_
;
std
::
atomic
<
bool
>
initialized
_
;
std
::
thread
bg_timer_thread_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录