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

curvefs/mds: fix create partition error at parallel case #1511

Merged
merged 1 commit into from
May 26, 2022
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
3 changes: 3 additions & 0 deletions curvefs/src/mds/topology/topology_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint32_t pNumber = topology_->GetPartitionNumberOfFs(fsId);
uint64_t idStart = pNumber * option_.idNumberInPartition;
uint64_t idEnd = (pNumber + 1) * option_.idNumberInPartition - 1;

if delete partition, the start and end will duplicate.
fix it or add a todo here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fix at another pr later.

if (topology_->GetAvailableCopysetNum()
< option_.minAvailableCopysetNum) {
Expand Down
2 changes: 2 additions & 0 deletions curvefs/src/mds/topology/topology_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class TopologyManager {
*/
NameLock registMsMutex;

NameLock createPartitionMutex_;

/**
* @brief topology options
*/
Expand Down