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

Fix meta's cleanup not work as expected #5321

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/kvstore/Part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "common/time/ScopedTimer.h"
#include "common/utils/IndexKeyUtils.h"
#include "common/utils/MetaKeyUtils.h"
#include "common/utils/NebulaKeyUtils.h"
#include "common/utils/OperationKeyUtils.h"
#include "common/utils/Utils.h"
Expand Down Expand Up @@ -487,6 +488,9 @@ bool Part::preProcessLog(LogID logId, TermID termId, ClusterID clusterId, folly:
}

nebula::cpp2::ErrorCode Part::cleanup() {
if (spaceId_ == kDefaultSpaceId && partId_ == kDefaultPartId) {
return metaCleanup();
}
LOG(INFO) << idStr_ << "Clean rocksdb part data";
auto batch = engine_->startBatchWrite();
// Remove the vertex, edge, index, systemCommitKey, operation data under the part
Expand Down Expand Up @@ -557,5 +561,13 @@ nebula::cpp2::ErrorCode Part::cleanup() {
std::move(batch), FLAGS_rocksdb_disable_wal, FLAGS_rocksdb_wal_sync, true);
}

nebula::cpp2::ErrorCode Part::metaCleanup() {
std::string kMetaPrefix = "__";
auto firstKey = NebulaKeyUtils::firstKey(kMetaPrefix, 1);
auto lastKey = NebulaKeyUtils::lastKey(kMetaPrefix, 1);
// todo(doodle): since the poor performance of DeleteRange, perhaps we need to compact
return engine_->removeRange(firstKey, lastKey);
}

} // namespace kvstore
} // namespace nebula
9 changes: 8 additions & 1 deletion src/kvstore/Part.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,19 @@ class Part : public raftex::RaftPart {
TermID committedLogTerm);

/**
* @brief clean up data in listener, called in RaftPart::reset
* @brief clean up data in storage part, called in RaftPart::reset
*
* @return nebula::cpp2::ErrorCode
*/
nebula::cpp2::ErrorCode cleanup() override;

/**
* @brief clean up data in meta part, called in RaftPart::reset
*
* @return nebula::cpp2::ErrorCode
*/
nebula::cpp2::ErrorCode metaCleanup();

public:
struct CallbackOptions {
GraphSpaceID spaceId;
Expand Down