diff --git a/curvefs/src/mds/topology/topology_manager.cpp b/curvefs/src/mds/topology/topology_manager.cpp index c0ae50d67b..09076205ba 100644 --- a/curvefs/src/mds/topology/topology_manager.cpp +++ b/curvefs/src/mds/topology/topology_manager.cpp @@ -632,6 +632,9 @@ void TopologyManager::CreatePartitions(const CreatePartitionRequest *request, auto partitionInfoList = response->mutable_partitioninfolist(); response->set_statuscode(TopoStatusCode::TOPO_OK); + // get lock and avoid multiMountpoint create concurrently + NameLockGuard lock(createPartitionMutex_, std::to_string(fsId)); + while (partitionInfoList->size() < count) { if (topology_->GetAvailableCopysetNum() < option_.minAvailableCopysetNum) { diff --git a/curvefs/src/mds/topology/topology_manager.h b/curvefs/src/mds/topology/topology_manager.h index 0a1d423461..66946b0b1b 100644 --- a/curvefs/src/mds/topology/topology_manager.h +++ b/curvefs/src/mds/topology/topology_manager.h @@ -186,6 +186,8 @@ class TopologyManager { */ NameLock registMsMutex; + NameLock createPartitionMutex_; + /** * @brief topology options */