Skip to content

Commit

Permalink
remove parts by storage's info before remove space
Browse files Browse the repository at this point in the history
  • Loading branch information
liwenhui-soul committed Mar 17, 2022
1 parent 9a401f7 commit 37c1406
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/kvstore/NebulaStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ NebulaStore::~NebulaStore() {
raftService_->stop();
LOG(INFO) << "Waiting for the raft service stop...";
raftService_->waitUntilStop();
spaces_.clear();
spaceListeners_.clear();
bgWorkers_->stop();
bgWorkers_->wait();
storeWorker_->stop();
storeWorker_->wait();
spaces_.clear();
spaceListeners_.clear();
LOG(INFO) << "~NebulaStore()";
}

Expand Down Expand Up @@ -392,6 +392,9 @@ void NebulaStore::removeSpace(GraphSpaceID spaceId, bool isListener) {
if (!isListener) {
auto spaceIt = this->spaces_.find(spaceId);
if (spaceIt != this->spaces_.end()) {
for (auto& [partId, part] : spaceIt->second->parts_) {
removePart(spaceId, partId, false);
}
auto& engines = spaceIt->second->engines_;
for (auto& engine : engines) {
auto parts = engine->allParts();
Expand Down Expand Up @@ -445,8 +448,11 @@ nebula::cpp2::ErrorCode NebulaStore::clearSpace(GraphSpaceID spaceId) {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

void NebulaStore::removePart(GraphSpaceID spaceId, PartitionID partId) {
folly::RWSpinLock::WriteHolder wh(&lock_);
void NebulaStore::removePart(GraphSpaceID spaceId, PartitionID partId, bool needLock) {
folly::RWSpinLock::WriteHolder wh(nullptr);
if (needLock) {
wh.reset(&lock_);
}
auto spaceIt = this->spaces_.find(spaceId);
if (spaceIt != this->spaces_.end()) {
auto partIt = spaceIt->second->parts_.find(partId);
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/NebulaStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ class NebulaStore : public KVStore, public Handler {
* @param spaceId
* @param partId
*/
void removePart(GraphSpaceID spaceId, PartitionID partId) override;
void removePart(GraphSpaceID spaceId, PartitionID partId, bool needLock = true) override;

/**
* @brief Retrive the leader distribution
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/PartManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Handler {
* @param spaceId
* @param partId
*/
virtual void removePart(GraphSpaceID spaceId, PartitionID partId) = 0;
virtual void removePart(GraphSpaceID spaceId, PartitionID partId, bool needLock = true) = 0;

/**
* @brief Add a partition as listener
Expand Down

0 comments on commit 37c1406

Please sign in to comment.