Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
4f3cc298
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4f3cc298
编写于
8月 04, 2020
作者:
Z
ZhaoMing
提交者:
赵明
8月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix WAL orderless bug of enabling prepare_log_writer_num
Fix WalManager's dysfunction of cleaning empty logs
上级
e635498c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
21 deletion
+24
-21
db/db_impl_write.cc
db/db_impl_write.cc
+14
-6
db/wal_manager.cc
db/wal_manager.cc
+8
-13
db/wal_manager.h
db/wal_manager.h
+2
-2
未找到文件。
db/db_impl_write.cc
浏览文件 @
4f3cc298
...
...
@@ -1516,12 +1516,20 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
// Log this later after lock release. It may be outdated, e.g., if background
// flush happens before logging, but that should be ok.
int
num_imm_unflushed
=
cfd
->
imm
()
->
NumNotFlushed
();
if
(
creating_new_log
&&
!
log_writer_pool_
.
empty
())
{
new_log
=
log_writer_pool_
.
front
().
release
();
log_writer_pool_
.
pop_front
();
new_log_number
=
new_log
->
get_log_number
();
}
else
if
(
creating_new_log
)
{
if
(
creating_new_log
)
{
while
(
!
log_writer_pool_
.
empty
())
{
auto
front
=
std
::
move
(
log_writer_pool_
.
front
());
log_writer_pool_
.
pop_front
();
if
(
front
->
get_log_number
()
>
new_log_number
)
{
new_log
=
front
.
release
();
new_log_number
=
new_log
->
get_log_number
();
break
;
}
else
{
logs_to_free_queue_
.
emplace_back
(
std
::
move
(
front
.
release
()));
}
}
}
if
(
creating_new_log
&&
new_log
==
nullptr
)
{
uint64_t
recycle_log_number
=
0
;
if
(
!
log_recycle_files_
.
empty
())
{
recycle_log_number
=
log_recycle_files_
.
front
();
...
...
db/wal_manager.cc
浏览文件 @
4f3cc298
...
...
@@ -86,14 +86,14 @@ Status WalManager::DeleteFile(const std::string& fname, uint64_t number) {
return
s
;
}
Status
WalManager
::
GetSortedWalFiles
(
VectorLogPtr
&
files
)
{
Status
WalManager
::
GetSortedWalFiles
(
VectorLogPtr
&
files
,
bool
allow_empty
)
{
// First get sorted files in db dir, then get sorted files from archived
// dir, to avoid a race condition where a log file is moved to archived
// dir in between.
Status
s
;
// list wal files in main db dir.
VectorLogPtr
logs
;
s
=
GetWalsOfType
(
db_options_
.
wal_dir
,
logs
,
kAliveLogFile
);
s
=
GetWalsOfType
(
db_options_
.
wal_dir
,
logs
,
kAliveLogFile
,
allow_empty
);
if
(
!
s
.
ok
())
{
return
s
;
}
...
...
@@ -109,7 +109,7 @@ Status WalManager::GetSortedWalFiles(VectorLogPtr& files) {
std
::
string
archivedir
=
ArchivalDirectory
(
db_options_
.
wal_dir
);
Status
exists
=
env_
->
FileExists
(
archivedir
);
if
(
exists
.
ok
())
{
s
=
GetWalsOfType
(
archivedir
,
files
,
kArchivedLogFile
);
s
=
GetWalsOfType
(
archivedir
,
files
,
kArchivedLogFile
,
allow_empty
);
if
(
!
s
.
ok
())
{
return
s
;
}
...
...
@@ -135,11 +135,6 @@ Status WalManager::GetSortedWalFiles(VectorLogPtr& files) {
// archived dir first, we would have missed the log file.
files
.
erase
(
std
::
unique
(
files
.
begin
(),
files
.
end
(),
EqualLogByPointer
()),
files
.
end
());
assert
(
std
::
is_sorted
(
files
.
begin
(),
files
.
end
(),
[](
const
std
::
unique_ptr
<
LogFile
>&
a
,
const
std
::
unique_ptr
<
LogFile
>&
b
)
{
return
a
->
StartSequence
()
<
b
->
StartSequence
();
}));
return
s
;
}
...
...
@@ -151,7 +146,7 @@ Status WalManager::GetUpdatesSince(
// Do binary search and open files and find the seq number.
std
::
unique_ptr
<
VectorLogPtr
>
wal_files
(
new
VectorLogPtr
);
Status
s
=
GetSortedWalFiles
(
*
wal_files
);
Status
s
=
GetSortedWalFiles
(
*
wal_files
,
false
/* allow_empty */
);
if
(
!
s
.
ok
())
{
return
s
;
}
...
...
@@ -201,7 +196,7 @@ void WalManager::PurgeObsoleteWALFiles() {
purge_wal_files_last_run_
=
now_seconds
;
VectorLogPtr
files
;
s
=
GetSortedWalFiles
(
files
);
s
=
GetSortedWalFiles
(
files
,
true
/* allow_empty */
);
if
(
!
s
.
ok
())
{
ROCKS_LOG_ERROR
(
db_options_
.
info_log
,
"GetSortedWalFiles fail: %s"
,
s
.
ToString
().
c_str
());
...
...
@@ -295,8 +290,8 @@ void WalManager::ArchiveWALFile(const std::string& fname, uint64_t number) {
}
Status
WalManager
::
GetWalsOfType
(
const
std
::
string
&
path
,
VectorLogPtr
&
log_files
,
WalFileType
log_type
)
{
VectorLogPtr
&
log_files
,
WalFileType
log_type
,
bool
allow_empty
)
{
std
::
vector
<
std
::
string
>
all_files
;
const
Status
status
=
env_
->
GetChildren
(
path
,
&
all_files
);
if
(
!
status
.
ok
())
{
...
...
@@ -312,7 +307,7 @@ Status WalManager::GetWalsOfType(const std::string& path,
if
(
!
s
.
ok
())
{
return
s
;
}
if
(
sequence
==
0
)
{
if
(
!
allow_empty
&&
sequence
==
0
)
{
// empty file
continue
;
}
...
...
db/wal_manager.h
浏览文件 @
4f3cc298
...
...
@@ -43,7 +43,7 @@ class WalManager {
uint64_t
GetNextLogNumber
(
const
uint64_t
number
);
Status
GetSortedWalFiles
(
VectorLogPtr
&
files
);
Status
GetSortedWalFiles
(
VectorLogPtr
&
files
,
bool
allow_empty
=
false
);
Status
GetUpdatesSince
(
SequenceNumber
seq_number
,
std
::
unique_ptr
<
TransactionLogIterator
>*
iter
,
...
...
@@ -72,7 +72,7 @@ class WalManager {
private:
Status
GetWalsOfType
(
const
std
::
string
&
path
,
VectorLogPtr
&
log_files
,
WalFileType
type
);
WalFileType
type
,
bool
allow_empty
);
// Requires: all_logs should be sorted with earliest log file first
// Retains all log files in all_logs which contain updates with seq no.
// Greater Than or Equal to the requested SequenceNumber.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录