Skip to content

Commit

Permalink
Fix meta's cleanup (#5517)
Browse files Browse the repository at this point in the history
Co-authored-by: Sophie <[email protected]>
  • Loading branch information
luyade and Sophie-Xie authored Apr 21, 2023
1 parent 7aeacd0 commit ac79d85
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/kvstore/Part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,25 @@ nebula::cpp2::ErrorCode Part::cleanup() {
}

nebula::cpp2::ErrorCode Part::metaCleanup() {
LOG(INFO) << idStr_ << "Clean rocksdb part data";
std::string kMetaPrefix = "__";
auto firstKey = NebulaKeyUtils::firstKey(kMetaPrefix, 1);
auto lastKey = NebulaKeyUtils::lastKey(kMetaPrefix, 1);
auto batch = engine_->startBatchWrite();
auto ret = batch->removeRange(firstKey, lastKey);
if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) {
VLOG(3) << idStr_ << "Failed to encode removeRange() when cleanup meta data, error "
<< apache::thrift::util::enumNameSafe(ret);
return ret;
}
ret = batch->remove(NebulaKeyUtils::systemCommitKey(partId_));
if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) {
VLOG(3) << idStr_ << "Remove the part system commit data failed, error "
<< apache::thrift::util::enumNameSafe(ret);
return ret;
}
// todo(doodle): since the poor performance of DeleteRange, perhaps we need to compact
return engine_->removeRange(firstKey, lastKey);
return engine_->commitBatchWrite(std::move(batch), false, FLAGS_rocksdb_wal_sync, true);
}

} // namespace kvstore
Expand Down

0 comments on commit ac79d85

Please sign in to comment.