Skip to content

Commit

Permalink
fix meta has not cleanup when reset (#5321)
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 authored Feb 8, 2023
1 parent 9e2523c commit c04dc94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit c04dc94

Please sign in to comment.