Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_35024513
milvus
提交
d0ee264b
milvus
项目概览
qq_35024513
/
milvus
与 Fork 源项目一致
Fork自
milvus / milvus
通知
14
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d0ee264b
编写于
3月 10, 2020
作者:
J
Jin Hai
提交者:
GitHub
3月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1610 from yhmo/binary
#1609 Refine Compact function
上级
4825f072
120ea4d0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
50 deletion
+23
-50
CHANGELOG.md
CHANGELOG.md
+1
-0
core/src/db/DBImpl.cpp
core/src/db/DBImpl.cpp
+22
-50
未找到文件。
CHANGELOG.md
浏览文件 @
d0ee264b
...
@@ -59,6 +59,7 @@ Please mark all change in change log and use the issue from GitHub
...
@@ -59,6 +59,7 @@ Please mark all change in change log and use the issue from GitHub
-
\#
1590 Server down caused by failure to write file during concurrent mixed operations
-
\#
1590 Server down caused by failure to write file during concurrent mixed operations
-
\#
1598 Server down during mixed operations
-
\#
1598 Server down during mixed operations
-
\#
1601 External link bug in HTTP doc
-
\#
1601 External link bug in HTTP doc
-
\#
1609 Refine Compact function
## Feature
## Feature
-
\#
216 Add CLI to get server info
-
\#
216 Add CLI to get server info
...
...
core/src/db/DBImpl.cpp
浏览文件 @
d0ee264b
...
@@ -671,26 +671,6 @@ DBImpl::Compact(const std::string& table_id) {
...
@@ -671,26 +671,6 @@ DBImpl::Compact(const std::string& table_id) {
ENGINE_LOG_DEBUG
<<
"Compacting table: "
<<
table_id
;
ENGINE_LOG_DEBUG
<<
"Compacting table: "
<<
table_id
;
/*
// Save table index
TableIndex table_index;
status = DescribeIndex(table_id, table_index);
if (!status.ok()) {
return status;
}
// Drop all index
status = DropIndex(table_id);
if (!status.ok()) {
return status;
}
// Then update table index to the previous index
status = UpdateTableIndexRecursively(table_id, table_index);
if (!status.ok()) {
return status;
}
*/
// Get files to compact from meta.
// Get files to compact from meta.
std
::
vector
<
int
>
file_types
{
meta
::
TableFileSchema
::
FILE_TYPE
::
RAW
,
meta
::
TableFileSchema
::
FILE_TYPE
::
TO_INDEX
,
std
::
vector
<
int
>
file_types
{
meta
::
TableFileSchema
::
FILE_TYPE
::
RAW
,
meta
::
TableFileSchema
::
FILE_TYPE
::
TO_INDEX
,
meta
::
TableFileSchema
::
FILE_TYPE
::
BACKUP
};
meta
::
TableFileSchema
::
FILE_TYPE
::
BACKUP
};
...
@@ -706,9 +686,11 @@ DBImpl::Compact(const std::string& table_id) {
...
@@ -706,9 +686,11 @@ DBImpl::Compact(const std::string& table_id) {
OngoingFileChecker
::
GetInstance
().
MarkOngoingFiles
(
files_to_compact
);
OngoingFileChecker
::
GetInstance
().
MarkOngoingFiles
(
files_to_compact
);
meta
::
TableFilesSchema
files_to_update
;
Status
compact_status
;
Status
compact_status
;
for
(
auto
&
file
:
files_to_compact
)
{
for
(
meta
::
TableFilesSchema
::
iterator
iter
=
files_to_compact
.
begin
();
iter
!=
files_to_compact
.
end
();)
{
meta
::
TableFileSchema
file
=
*
iter
;
iter
=
files_to_compact
.
erase
(
iter
);
// Check if the segment needs compacting
// Check if the segment needs compacting
std
::
string
segment_dir
;
std
::
string
segment_dir
;
utils
::
GetParentPath
(
file
.
location_
,
segment_dir
);
utils
::
GetParentPath
(
file
.
location_
,
segment_dir
);
...
@@ -719,52 +701,42 @@ DBImpl::Compact(const std::string& table_id) {
...
@@ -719,52 +701,42 @@ DBImpl::Compact(const std::string& table_id) {
if
(
!
status
.
ok
())
{
if
(
!
status
.
ok
())
{
std
::
string
msg
=
"Failed to load deleted_docs from "
+
segment_dir
;
std
::
string
msg
=
"Failed to load deleted_docs from "
+
segment_dir
;
ENGINE_LOG_ERROR
<<
msg
;
ENGINE_LOG_ERROR
<<
msg
;
return
Status
(
DB_ERROR
,
msg
);
OngoingFileChecker
::
GetInstance
().
UnmarkOngoingFile
(
file
);
continue
;
// skip this file and try compact next one
}
}
meta
::
TableFilesSchema
files_to_update
;
if
(
deleted_docs
->
GetSize
()
!=
0
)
{
if
(
deleted_docs
->
GetSize
()
!=
0
)
{
compact_status
=
CompactFile
(
table_id
,
file
,
files_to_update
);
compact_status
=
CompactFile
(
table_id
,
file
,
files_to_update
);
if
(
!
compact_status
.
ok
())
{
if
(
!
compact_status
.
ok
())
{
ENGINE_LOG_ERROR
<<
"Compact failed for segment "
<<
file
.
segment_id_
<<
": "
ENGINE_LOG_ERROR
<<
"Compact failed for segment "
<<
file
.
segment_id_
<<
": "
<<
compact_status
.
message
();
<<
compact_status
.
message
();
break
;
OngoingFileChecker
::
GetInstance
().
UnmarkOngoingFile
(
file
);
continue
;
// skip this file and try compact next one
}
}
}
else
{
}
else
{
OngoingFileChecker
::
GetInstance
().
UnmarkOngoingFile
(
file
);
ENGINE_LOG_DEBUG
<<
"Segment "
<<
file
.
segment_id_
<<
" has no deleted data. No need to compact"
;
ENGINE_LOG_DEBUG
<<
"Segment "
<<
file
.
segment_id_
<<
" has no deleted data. No need to compact"
;
continue
;
// skip this file and try compact next one
}
}
}
if
(
compact_status
.
ok
())
{
ENGINE_LOG_DEBUG
<<
"Finished compacting table: "
<<
table_id
;
}
ENGINE_LOG_DEBUG
<<
"Updating meta after compaction..."
;
ENGINE_LOG_DEBUG
<<
"Updating meta after compaction..."
;
status
=
meta_ptr_
->
UpdateTableFiles
(
files_to_update
);
/*
OngoingFileChecker
::
GetInstance
().
UnmarkOngoingFile
(
file
);
// Drop index again, in case some files were in the index building process during compacting
if
(
!
status
.
ok
())
{
status = DropIndex(table_id);
compact_status
=
status
;
if (!status.ok()) {
break
;
// meta error, could not go on
return status;
}
}
// Update index
status = UpdateTableIndexRecursively(table_id, table_index);
if (!status.ok()) {
return status;
}
*/
status
=
meta_ptr_
->
UpdateTableFiles
(
files_to_update
);
if
(
!
status
.
ok
())
{
return
status
;
}
}
OngoingFileChecker
::
GetInstance
().
UnmarkOngoingFiles
(
files_to_compact
);
OngoingFileChecker
::
GetInstance
().
UnmarkOngoingFiles
(
files_to_compact
);
ENGINE_LOG_DEBUG
<<
"Finished updating meta after compaction"
;
if
(
compact_status
.
ok
())
{
ENGINE_LOG_DEBUG
<<
"Finished compacting table: "
<<
table_id
;
}
return
status
;
return
compact_
status
;
}
}
Status
Status
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录