Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
5e60e610
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,发现更多精彩内容 >>
未验证
提交
5e60e610
编写于
9月 28, 2020
作者:
G
groot
提交者:
GitHub
9月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add wal sync config (#3899)
Signed-off-by:
N
groot
<
yihua.mo@zilliz.com
>
上级
45ecc9ae
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
5 deletion
+25
-5
core/src/config/ConfigInit.cpp
core/src/config/ConfigInit.cpp
+1
-0
core/src/config/ServerConfig.h
core/src/config/ServerConfig.h
+1
-0
core/src/db/wal/WalFile.cpp
core/src/db/wal/WalFile.cpp
+3
-0
core/src/db/wal/WalFile.h
core/src/db/wal/WalFile.h
+13
-2
core/src/db/wal/WalManager.cpp
core/src/db/wal/WalManager.cpp
+6
-3
core/src/db/wal/WalManager.h
core/src/db/wal/WalManager.h
+1
-0
未找到文件。
core/src/config/ConfigInit.cpp
浏览文件 @
5e60e610
...
...
@@ -103,6 +103,7 @@ InitConfig() {
/* wal */
{
"wal.enable"
,
CreateBoolConfig
(
"wal.enable"
,
&
config
.
wal
.
enable
.
value
,
true
)},
{
"wal.sync_mode"
,
CreateBoolConfig
(
"wal.sync_mode"
,
&
config
.
wal
.
sync_mode
.
value
,
false
)},
{
"wal.recovery_error_ignore"
,
CreateBoolConfig
(
"wal.recovery_error_ignore"
,
&
config
.
wal
.
recovery_error_ignore
.
value
,
false
)},
{
"wal.buffer_size"
,
...
...
core/src/config/ServerConfig.h
浏览文件 @
5e60e610
...
...
@@ -136,6 +136,7 @@ struct ServerConfig {
struct
WAL
{
Bool
enable
{
false
};
Bool
sync_mode
{
false
};
Bool
recovery_error_ignore
{
false
};
Integer
buffer_size
{
0
};
String
path
{
"unknown"
};
...
...
core/src/db/wal/WalFile.cpp
浏览文件 @
5e60e610
...
...
@@ -21,6 +21,9 @@
namespace
milvus
{
namespace
engine
{
WalFile
::
WalFile
(
bool
sync
)
:
sync_
(
sync
)
{
}
WalFile
::~
WalFile
()
{
CloseFile
();
}
...
...
core/src/db/wal/WalFile.h
浏览文件 @
5e60e610
...
...
@@ -14,6 +14,7 @@
#include "db/Types.h"
#include "utils/Status.h"
#include <unistd.h>
#include <map>
#include <memory>
#include <mutex>
...
...
@@ -24,7 +25,7 @@ namespace engine {
class
WalFile
{
public:
WalFile
()
=
default
;
explicit
WalFile
(
bool
sync
=
false
)
;
virtual
~
WalFile
();
bool
...
...
@@ -107,7 +108,12 @@ class WalFile {
inline
void
Flush
()
{
if
(
file_
&&
mode_
!=
OpenMode
::
READ
)
{
fflush
(
file_
);
if
(
sync_
)
{
int
fd
=
fileno
(
file_
);
fsync
(
fd
);
}
else
{
fflush
(
file_
);
}
}
}
...
...
@@ -136,6 +142,11 @@ class WalFile {
OpenMode
mode_
=
OpenMode
::
NA
;
int64_t
file_size_
=
0
;
std
::
string
file_path_
;
// fflush() or fsync() to flush data into storage
// fflush() flush data to system kernel buffer, ensure data safety even milvus crashed
// fsync() flush data into to hard disk(much slower), ensure data safety even the machine shutdown or blackout
bool
sync_
=
false
;
};
using
WalFilePtr
=
std
::
shared_ptr
<
WalFile
>
;
...
...
core/src/db/wal/WalManager.cpp
浏览文件 @
5e60e610
...
...
@@ -10,6 +10,7 @@
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "db/wal/WalManager.h"
#include "config/ServerConfig.h"
#include "db/Utils.h"
#include "db/wal/WalOperationCodec.h"
#include "utils/CommonUtil.h"
...
...
@@ -224,7 +225,7 @@ WalManager::Recovery(const DBPtr& db, const CollectionMaxOpIDMap& max_op_ids) {
// id_files arrange id in assendent, we know which file should be read
for
(
auto
&
pair
:
id_files
)
{
WalFilePtr
file
=
std
::
make_shared
<
WalFile
>
();
WalFilePtr
file
=
std
::
make_shared
<
WalFile
>
(
sync_mode_
);
file
->
OpenFile
(
pair
.
second
.
c_str
(),
WalFile
::
READ
);
idx_t
last_id
=
0
;
file
->
ReadLastOpId
(
last_id
);
...
...
@@ -259,6 +260,8 @@ WalManager::Recovery(const DBPtr& db, const CollectionMaxOpIDMap& max_op_ids) {
Status
WalManager
::
Init
()
{
sync_mode_
=
config
.
wal
.
sync_mode
();
try
{
using
DirectoryIterator
=
std
::
experimental
::
filesystem
::
recursive_directory_iterator
;
DirectoryIterator
iter
(
wal_path_
);
...
...
@@ -312,7 +315,7 @@ WalManager::RecordInsertOperation(const InsertEntityOperationPtr& operation, con
std
::
lock_guard
<
std
::
mutex
>
lock
(
file_map_mutex_
);
WalFilePtr
file
=
file_map_
[
operation
->
collection_name_
];
if
(
file
==
nullptr
)
{
file
=
std
::
make_shared
<
WalFile
>
();
file
=
std
::
make_shared
<
WalFile
>
(
sync_mode_
);
file_map_
[
operation
->
collection_name_
]
=
file
;
file
->
OpenFile
(
path
,
WalFile
::
APPEND_WRITE
);
}
else
if
(
!
file
->
IsOpened
()
||
file
->
ExceedMaxSize
(
chunk_size
))
{
...
...
@@ -353,7 +356,7 @@ WalManager::RecordDeleteOperation(const DeleteEntityOperationPtr& operation, con
std
::
lock_guard
<
std
::
mutex
>
lock
(
file_map_mutex_
);
WalFilePtr
file
=
file_map_
[
operation
->
collection_name_
];
if
(
file
==
nullptr
)
{
file
=
std
::
make_shared
<
WalFile
>
();
file
=
std
::
make_shared
<
WalFile
>
(
sync_mode_
);
file_map_
[
operation
->
collection_name_
]
=
file
;
file
->
OpenFile
(
path
,
WalFile
::
APPEND_WRITE
);
}
else
if
(
!
file
->
IsOpened
()
||
file
->
ExceedMaxSize
(
append_size
))
{
...
...
core/src/db/wal/WalManager.h
浏览文件 @
5e60e610
...
...
@@ -96,6 +96,7 @@ class WalManager {
SafeIDGenerator
id_gen_
;
bool
enable_
=
false
;
bool
sync_mode_
=
false
;
std
::
string
wal_path_
;
int64_t
insert_buffer_size_
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录