-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: maintain the logidx-seqno in SST files #246
feat: maintain the logidx-seqno in SST files #246
Conversation
longfar-ncy
commented
Mar 30, 2024
•
edited by dingxiaoshuai123
Loading
edited by dingxiaoshuai123
- Storage 中的 Redis 类封装了一个 RocksDB, 在 Redis 对象内增加一个队列,该队列保存了 raft applied log index 和 RocksDB 内所有 CF sequence number 的映射关系关系
- 每次 apply 写入成功后向该队列追加 log index 和 sequence number 的映射
- 增加一个 prop, 产生新 SST 文件的时候,通过该队列找到该 SST 文件中最大 sequence number 对应的 log index,并写入该 SST 文件的 prop meta block 进行持久化.
- 监听 Flush 事件, 每次 Flush 完成后,清理队列中不再有用的映射关系.
834534d
to
56d8abd
Compare
@@ -42,6 +42,7 @@ enum ColumnFamilyIndex { | |||
kZsetsMetaCF = 7, | |||
kZsetsDataCF = 8, | |||
kZsetsScoreCF = 9, | |||
kColumnFamilyNum, |
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.
这里应该给个赋值?
src/storage/src/log_index.cc
Outdated
auto res = sscanf(s.c_str(), "%" PRIi64 "/%" PRIu64 "", &applied_log_index, &largest_seqno); | ||
assert(res == 2); | ||
|
||
LogIndexAndSequencePair p(applied_log_index, largest_seqno); |
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.
return LogIndexAndSequencePair(applied_log_index, largest_seqno);
src/storage/src/log_index.h
Outdated
// cf_[cf_id].applied_log_index = std::max(cf_[cf_id].applied_log_index.load(), cur_log_index); | ||
// return cur_log_index == cf_[cf_id].applied_log_index.load(); | ||
// } | ||
bool IsAppliedOrUpdate(size_t cf_id, LogIndex cur_log_index) { |
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.
IsApplied可能就够了,就是命名上还是有点问题,会误以为只是判断实际上还有隐式的置值。
src/storage/src/storage.cc
Outdated
for (const auto& entry : log.entries()) { | ||
// If the log has been applied, skip it. Otherwise, update the logidx of the column family. | ||
if (inst->IsRestarting() && inst->IsAppliedOrUpdate(entry.cf_idx(), log_idx)) { |
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.
这里可以加个hint unlikely(),表示正常情况不会走进来。
4e7ade7
to
59d5a2b
Compare
This reverts commit 59d5a2b.
20123ef
to
6b3d2fa
Compare