Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
dc9ef8f8
Incubator Pegasus
项目概览
apache
/
Incubator Pegasus
通知
9
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Incubator Pegasus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dc9ef8f8
编写于
1月 14, 2019
作者:
Q
QinZuoyan
提交者:
qinzuoyan
2月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pegasus-server: remove old checkpoints after manual compact to releas… (#253)
上级
16c53ff6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
8 deletion
+37
-8
src/base/pegasus_const.cpp
src/base/pegasus_const.cpp
+1
-1
src/server/pegasus_server_impl.cpp
src/server/pegasus_server_impl.cpp
+34
-6
src/server/pegasus_server_impl.h
src/server/pegasus_server_impl.h
+2
-1
未找到文件。
src/base/pegasus_const.cpp
浏览文件 @
dc9ef8f8
...
...
@@ -56,7 +56,7 @@ const std::string MANUAL_COMPACT_BOTTOMMOST_LEVEL_COMPACTION_FORCE("force");
const
std
::
string
MANUAL_COMPACT_BOTTOMMOST_LEVEL_COMPACTION_SKIP
(
"skip"
);
/// default ttl for items in a table. If ttl is not set for
/// * a new writen item, 'default_ttl' will be applied on this item.
/// * a new writ
t
en item, 'default_ttl' will be applied on this item.
/// * an exist item, 'default_ttl' will be applied on this item when it was compacted.
/// <= 0 means no effect
const
std
::
string
TABLE_LEVEL_DEFAULT_TTL
(
"default_ttl"
);
...
...
src/server/pegasus_server_impl.cpp
浏览文件 @
dc9ef8f8
...
...
@@ -388,12 +388,14 @@ void pegasus_server_impl::parse_checkpoints()
pegasus_server_impl
::~
pegasus_server_impl
()
=
default
;
void
pegasus_server_impl
::
gc_checkpoints
()
void
pegasus_server_impl
::
gc_checkpoints
(
bool
force_reserve_one
)
{
int
min_count
=
force_reserve_one
?
1
:
_checkpoint_reserve_min_count
;
uint64_t
reserve_time
=
force_reserve_one
?
0
:
_checkpoint_reserve_time_seconds
;
std
::
deque
<
int64_t
>
temp_list
;
{
::
dsn
::
utils
::
auto_lock
<::
dsn
::
utils
::
ex_lock_nr
>
l
(
_checkpoints_lock
);
if
(
_checkpoints
.
size
()
<=
_checkpoint_reserve_
min_count
)
if
(
_checkpoints
.
size
()
<=
min_count
)
return
;
temp_list
=
_checkpoints
;
}
...
...
@@ -402,10 +404,10 @@ void pegasus_server_impl::gc_checkpoints()
int64_t
max_del_d
=
-
1
;
uint64_t
current_time
=
dsn_now_ms
()
/
1000
;
for
(
int
i
=
0
;
i
<
temp_list
.
size
();
++
i
)
{
if
(
i
+
_checkpoint_reserve_
min_count
>=
temp_list
.
size
())
if
(
i
+
min_count
>=
temp_list
.
size
())
break
;
int64_t
d
=
temp_list
[
i
];
if
(
_checkpoint_reserve_time_seconds
>
0
)
{
if
(
reserve_time
>
0
)
{
// we check last write time of "CURRENT" instead of directory, because the directory's
// last write time may be updated by previous incompleted garbage collection.
auto
cpt_dir
=
...
...
@@ -421,7 +423,7 @@ void pegasus_server_impl::gc_checkpoints()
break
;
}
uint64_t
last_write_time
=
(
uint64_t
)
tm
;
if
(
last_write_time
+
_checkpoint_reserve_time_seconds
>=
current_time
)
{
if
(
last_write_time
+
reserve_time
>=
current_time
)
{
// not expired
break
;
}
...
...
@@ -444,7 +446,7 @@ void pegasus_server_impl::gc_checkpoints()
int
delete_max_index
=
-
1
;
for
(
int
i
=
0
;
i
<
_checkpoints
.
size
();
++
i
)
{
int64_t
del_d
=
_checkpoints
[
i
];
if
(
i
+
_checkpoint_reserve_
min_count
>=
_checkpoints
.
size
()
||
del_d
>
max_del_d
)
if
(
i
+
min_count
>=
_checkpoints
.
size
()
||
del_d
>
max_del_d
)
break
;
to_delete_list
.
push_back
(
del_d
);
delete_max_index
=
i
;
...
...
@@ -2612,6 +2614,32 @@ uint64_t pegasus_server_impl::do_manual_compact(const rocksdb::CompactRangeOptio
status
.
ToString
().
c_str
(),
dsn_now_ms
()
-
start_time
);
// generate new checkpoint and remove old checkpoints, in order to release storage asap
ddebug_replica
(
"generate new checkpoint immediately after manual compact"
);
int64_t
old_last_durable
=
last_durable_decree
();
sync_checkpoint
();
gc_checkpoints
(
true
);
if
(
last_durable_decree
()
==
old_last_durable
)
{
// it is possible that the new checkpoint is not generated, if there was no data
// written into rocksdb when doing manual compact.
ddebug_replica
(
"no new checkpoint generated, will retry after 5 minutes"
);
::
dsn
::
tasking
::
enqueue
(
LPC_PEGASUS_SERVER_DELAY
,
&
_tracker
,
[
this
,
old_last_durable
]()
{
ddebug_replica
(
"retry gc checkpoints after manual compact"
);
if
(
last_durable_decree
()
==
old_last_durable
)
{
// if the new checkpoint is still not generated in the
// last 5 minutes, we will try to generate it again, and
// it will probably succeed because at least some empty
// data is written into rocksdb by periodic group check.
sync_checkpoint
();
}
gc_checkpoints
(
true
);
},
0
,
std
::
chrono
::
minutes
(
5
));
}
// update rocksdb statistics immediately
update_replica_rocksdb_statistics
();
...
...
src/server/pegasus_server_impl.h
浏览文件 @
dc9ef8f8
...
...
@@ -162,7 +162,8 @@ private:
void
parse_checkpoints
();
// garbage collection checkpoints
void
gc_checkpoints
();
// if force_reserve_one == true, then only reserve the last one checkpoint
void
gc_checkpoints
(
bool
force_reserve_one
=
false
);
void
set_last_durable_decree
(
int64_t
decree
)
{
_last_durable_decree
.
store
(
decree
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录