-
Notifications
You must be signed in to change notification settings - Fork 311
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
Conversation
在manual compact的时候,sstable会被重新生成。但是旧的sstable文件还被checkpoint持有,如果不及时释放,会占据较多存储空间,存储用量有可能突增一倍以上。如果原本pegasus的存储用量已经较大(譬如超过50%),就有磁盘使用耗尽造成系统崩溃的风险。 因此,在manual compact执行完成后,有必要生成新的checkpoint,并把老的checkpoint都删除掉,以及时释放存储空间。 |
src/server/pegasus_server_impl.cpp
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
written
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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一次?
There was a problem hiding this comment.
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),强制只保留一个,这样就保证把老的都删除了。
There was a problem hiding this comment.
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) 是强行只保留一个
There was a problem hiding this comment.
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的参数
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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的,这样就不用先按照通常规则保留多个,再强制保留一个
There was a problem hiding this comment.
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个数的实现细节也不应当暴露在接口中
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,好
apache#253) Former-commit-id: 8fcb66021af9297a304018aa7902922a01f8219b [formerly 6cfd2ac] Former-commit-id: 1f987f47dca543044827e9a21ce1db6a1dea69a7
…e storage