Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pegasus-server: remove old checkpoints after manual compact to releas… #253

Merged
merged 3 commits into from
Jan 14, 2019

Conversation

qinzuoyan
Copy link
Contributor

…e storage

@qinzuoyan qinzuoyan added the type/enhancement Indicates new feature requests label Jan 12, 2019
@qinzuoyan qinzuoyan self-assigned this Jan 12, 2019
@qinzuoyan
Copy link
Contributor Author

在manual compact的时候,sstable会被重新生成。但是旧的sstable文件还被checkpoint持有,如果不及时释放,会占据较多存储空间,存储用量有可能突增一倍以上。如果原本pegasus的存储用量已经较大(譬如超过50%),就有磁盘使用耗尽造成系统崩溃的风险。

因此,在manual compact执行完成后,有必要生成新的checkpoint,并把老的checkpoint都删除掉,以及时释放存储空间。

@qinzuoyan qinzuoyan changed the title replica-server: remove old checkpoints after manual compact to releas… pegasus-server: remove old checkpoints after manual compact to releas… Jan 12, 2019
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
// writen into rocksdb when doing manual compact.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

written

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// 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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sync_checkpoint最后就会gc_checkpoints,这里调用结束后又gc一次?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两次调用是不一样的:

  • sync_checkpoint()函数里面调用gc_checkpoint(),是按照通常的规则来gc,依赖于reserve_min_count和reserve_time_seconds参数,有可能依然会保留多个checkpoint。
  • 在sync_checkpoint()外面再调用gc_checkpoint(true),强制只保留一个,这样就保证把老的都删除了。

Copy link
Contributor

@neverchanje neverchanje Jan 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sync_checkpoint 最后的 gc_checkpoints() 默认会保留 3 个 checkpoints(checkpoint_reserve_min_count),这里 gc_checkpoints(true) 是强行只保留一个

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,gc_checkpoints方法加了一个force_reserve_one的参数

Copy link
Contributor Author

@qinzuoyan qinzuoyan Jan 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

而且 gc_checkpoints() 也不是默认保留3个,而是依赖reserve_min_count和reserve_time_seconds参数,并且还是可以动态调整的,参见 #252

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我明白这个意思,我想说的是能不能直接修改sync_checkpoint的参数,比如改成sync_checkpoint(true), 这样最后调用的gc_checkpoints就是只保留一个checkpoint的,这样就不用先按照通常规则保留多个,再强制保留一个

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sync_checkpoint是rrdb_service的接口,改动的话涉及比较多,而且这种保留checkpoint个数的实现细节也不应当暴露在接口中

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,好

neverchanje
neverchanje previously approved these changes Jan 14, 2019
hycdong
hycdong previously approved these changes Jan 14, 2019
@qinzuoyan qinzuoyan dismissed stale reviews from hycdong and neverchanje via 6a10fbe January 14, 2019 06:39
@qinzuoyan qinzuoyan merged commit 6cfd2ac into master Jan 14, 2019
@qinzuoyan qinzuoyan deleted the qinzuoyan1 branch January 14, 2019 07:27
neverchanje pushed a commit to neverchanje/pegasus that referenced this pull request Jul 13, 2019
apache#253)

Former-commit-id: 8fcb66021af9297a304018aa7902922a01f8219b [formerly 6cfd2ac]
Former-commit-id: 1f987f47dca543044827e9a21ce1db6a1dea69a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants