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 16, 2022
1 parent 9a401f7 commit 6374780
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/kvstore/NebulaStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ namespace kvstore {
NebulaStore::~NebulaStore() {
LOG(INFO) << "Cut off the relationship with meta client";
options_.partMan_.reset();
<<<<<<< Updated upstream
raftService_->stop();
LOG(INFO) << "Waiting for the raft service stop...";
raftService_->waitUntilStop();
spaces_.clear();
spaceListeners_.clear();
=======
>>>>>>> Stashed changes
bgWorkers_->stop();
bgWorkers_->wait();
storeWorker_->stop();
storeWorker_->wait();
spaces_.clear();
spaceListeners_.clear();
LOG(INFO) << "~NebulaStore()";
}

Expand Down Expand Up @@ -392,6 +397,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 +453,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 6374780

Please sign in to comment.