Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
d30897b8
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,发现更多精彩内容 >>
提交
d30897b8
编写于
1月 11, 2021
作者:
U
ustcwelcome
提交者:
奏之章
2月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug-fix of markcompaction
上级
a4d77e92
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
29 deletion
+41
-29
db/db_impl.cc
db/db_impl.cc
+24
-15
db/version_set.cc
db/version_set.cc
+17
-14
未找到文件。
db/db_impl.cc
浏览文件 @
d30897b8
...
...
@@ -932,9 +932,9 @@ void DBImpl::ScheduleGCTTL() {
auto
should_marked_for_compacted
=
[
&
](
uint64_t
ratio_expire_time
,
uint64_t
scan_gap_expire_time
,
uint64_t
now
)
{
ROCKS_LOG_INFO
(
immutable_db_options_
.
info_log
,
"SST Table property info:%"
PRIu64
",%"
PRIu64
",%"
PRIu64
,
ratio_expire_time
,
scan_gap_expire_time
,
now
);
//
ROCKS_LOG_INFO(immutable_db_options_.info_log,
// "SST Table property info:%" PRIu64 ",%" PRIu64 ",%"
// PRIu64,
ratio_expire_time, scan_gap_expire_time, now);
return
(
std
::
min
(
ratio_expire_time
,
scan_gap_expire_time
)
<=
now
);
};
ROCKS_LOG_INFO
(
immutable_db_options_
.
info_log
,
"Start ScheduleGCTTL"
);
...
...
@@ -945,26 +945,35 @@ void DBImpl::ScheduleGCTTL() {
VersionStorageInfo
*
vsi
=
cfd
->
current
()
->
storage_info
();
for
(
int
l
=
0
;
l
<
vsi
->
num_levels
();
l
++
)
{
for
(
auto
sst
:
vsi
->
LevelFiles
(
l
))
{
if
(
sst
->
marked_for_compaction
)
marked_count
++
;
if
(
!
sst
->
marked_for_compaction
)
sst
->
marked_for_compaction
=
should_marked_for_compacted
(
sst
->
prop
.
ratio_expire_time
,
sst
->
prop
.
scan_gap_expire_time
,
nowSeconds
);
if
(
sst
->
marked_for_compaction
)
{
marked_count
++
;
}
else
if
(
should_marked_for_compacted
(
sst
->
prop
.
ratio_expire_time
,
sst
->
prop
.
scan_gap_expire_time
,
nowSeconds
))
{
sst
->
marked_for_compaction
=
true
;
}
if
(
sst
->
marked_for_compaction
)
{
TEST_SYNC_POINT
(
"DBImpl:ScheduleGCTTL-mark"
);
mark_count
++
;
}
}
}
if
(
mark_count
>
0
)
{
vsi
->
ComputeCompactionScore
(
*
cfd
->
ioptions
(),
*
cfd
->
GetLatestMutableCFOptions
());
InstrumentedMutexLock
l
(
&
mutex_
);
AddToCompactionQueue
(
cfd
);
unscheduled_compactions_
++
;
MaybeScheduleFlushOrCompaction
();
}
ROCKS_LOG_INFO
(
immutable_db_options_
.
info_log
,
"[%s] marked for compact SST: %d, %d, %d"
,
cfd
->
GetName
().
c_str
(),
marked_count
,
mark_count
,
cnt
);
marked_count
=
0
;
mark_count
=
0
;
cnt
=
0
;
}
}
ROCKS_LOG_INFO
(
immutable_db_options_
.
info_log
,
"marked for compact SST: %d,%d,%d"
,
marked_count
,
mark_count
,
cnt
);
if
(
mark_count
>
0
)
{
InstrumentedMutexLock
l
(
&
mutex_
);
MaybeScheduleFlushOrCompaction
();
}
}
void
DBImpl
::
DumpStats
()
{
TEST_SYNC_POINT
(
"DBImpl::DumpStats:1"
);
...
...
db/version_set.cc
浏览文件 @
d30897b8
...
...
@@ -71,7 +71,7 @@ int FindFileInRange(const InternalKeyComparator& icmp,
uint32_t
left
,
uint32_t
right
)
{
return
static_cast
<
int
>
(
terark
::
lower_bound_ex_n
(
file_level
.
files
,
left
,
right
,
key
,
TERARK_FIELD
(
largest_key
),
""
<
icmp
));
TERARK_FIELD
(
largest_key
),
""
<
icmp
));
}
Status
OverlapWithIterator
(
const
Comparator
*
ucmp
,
...
...
@@ -2117,8 +2117,7 @@ void VersionStorageInfo::GenerateLevel0NonOverlapping() {
level_files_brief_
[
0
].
files
,
level_files_brief_
[
0
].
files
+
level_files_brief_
[
0
].
num_files
);
auto
icmp
=
internal_comparator_
;
terark
::
sort_a
(
level0_sorted_file
,
TERARK_FIELD
(
smallest_key
)
<
*
icmp
);
terark
::
sort_a
(
level0_sorted_file
,
TERARK_FIELD
(
smallest_key
)
<
*
icmp
);
for
(
size_t
i
=
1
;
i
<
level0_sorted_file
.
size
();
++
i
)
{
FdWithKeyRange
&
f
=
level0_sorted_file
[
i
];
...
...
@@ -2167,18 +2166,22 @@ void VersionStorageInfo::ComputeBottommostFilesMarkedForCompaction() {
bottommost_files_marked_for_compaction_
.
clear
();
bottommost_files_mark_threshold_
=
kMaxSequenceNumber
;
for
(
auto
&
level_and_file
:
bottommost_files_
)
{
if
(
!
level_and_file
.
second
->
being_compacted
&&
level_and_file
.
second
->
fd
.
largest_seqno
!=
0
&&
level_and_file
.
second
->
prop
.
num_deletions
>
1
)
{
// largest_seqno might be nonzero due to containing the final key in an
// earlier compaction, whose seqnum we didn't zero out. Multiple deletions
// ensures the file really contains deleted or overwritten keys.
if
(
level_and_file
.
second
->
fd
.
largest_seqno
<
oldest_snapshot_seqnum_
)
{
if
(
!
level_and_file
.
second
->
being_compacted
)
{
if
(
level_and_file
.
second
->
fd
.
largest_seqno
!=
0
&&
level_and_file
.
second
->
prop
.
num_deletions
>
1
)
{
// largest_seqno might be nonzero due to containing the final key in an
// earlier compaction, whose seqnum we didn't zero out. Multiple
// deletions ensures the file really contains deleted or overwritten
// keys.
if
(
level_and_file
.
second
->
fd
.
largest_seqno
<
oldest_snapshot_seqnum_
)
{
bottommost_files_marked_for_compaction_
.
push_back
(
level_and_file
);
}
else
{
bottommost_files_mark_threshold_
=
std
::
min
(
bottommost_files_mark_threshold_
,
level_and_file
.
second
->
fd
.
largest_seqno
);
}
}
else
if
(
level_and_file
.
second
->
marked_for_compaction
)
{
bottommost_files_marked_for_compaction_
.
push_back
(
level_and_file
);
}
else
{
bottommost_files_mark_threshold_
=
std
::
min
(
bottommost_files_mark_threshold_
,
level_and_file
.
second
->
fd
.
largest_seqno
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录