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

fix(master): if init data partitions failed when create volume, mark volume status as delete to trigger background deletion. #2653

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
22 changes: 17 additions & 5 deletions master/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3094,35 +3094,47 @@

vol.Status = markDelete
if e := vol.deleteVolFromStore(c); e != nil {
log.LogErrorf("action[createVol] failed,vol[%v] err[%v]", vol.Name, e)
log.LogErrorf("action[createVol] deleteVolFromStore failed, vol[%v] err[%v]", vol.Name, e)

Check warning on line 3097 in master/cluster.go

View check run for this annotation

Codecov / codecov/patch

master/cluster.go#L3097

Added line #L3097 was not covered by tests
}

c.deleteVol(req.name)

err = fmt.Errorf("action[createVol] initMetaPartitions failed,err[%v]", err)
err = fmt.Errorf("action[createVol] initMetaPartitions failed, vol[%v] err[%v]", vol.Name, err)
goto errHandler
}

if vol.CacheCapacity > 0 || (proto.IsHot(vol.VolType) && vol.Capacity > 0) {
for retryCount := 0; readWriteDataPartitions < defaultInitMetaPartitionCount && retryCount < 3; retryCount++ {
err = vol.initDataPartitions(c)
if err != nil {
log.LogError("init dataPartition error", err.Error(), retryCount, len(vol.dataPartitions.partitionMap))
log.LogError("action[createVol] init dataPartition error ",
err.Error(), retryCount, len(vol.dataPartitions.partitionMap))

Check warning on line 3111 in master/cluster.go

View check run for this annotation

Codecov / codecov/patch

master/cluster.go#L3110-L3111

Added lines #L3110 - L3111 were not covered by tests
}

readWriteDataPartitions = len(vol.dataPartitions.partitionMap)
}

if len(vol.dataPartitions.partitionMap) < defaultInitMetaPartitionCount {
err = fmt.Errorf("action[createVol] initDataPartitions failed, less than %d", defaultInitMetaPartitionCount)
err = fmt.Errorf("action[createVol] vol[%v] initDataPartitions failed, less than %d",
vol.Name, defaultInitMetaPartitionCount)

oldVolStatus := vol.Status
vol.Status = markDelete
if err = c.syncUpdateVol(vol); err != nil {
log.LogErrorf("action[createVol] vol[%v] after init dataPartition error, mark vol delete persist failed", vol.Name)
vol.Status = oldVolStatus
} else {
log.LogErrorf("action[createVol] vol[%v] mark vol delete after init dataPartition error", vol.Name)
}

Check warning on line 3128 in master/cluster.go

View check run for this annotation

Codecov / codecov/patch

master/cluster.go#L3118-L3128

Added lines #L3118 - L3128 were not covered by tests

goto errHandler
}
}

vol.dataPartitions.readableAndWritableCnt = readWriteDataPartitions
vol.updateViewCache(c)

log.LogInfof("action[createVol] vol[%v],readableAndWritableCnt[%v]", req.name, readWriteDataPartitions)
log.LogInfof("action[createVol] vol[%v], readableAndWritableCnt[%v]", req.name, readWriteDataPartitions)
return

errHandler:
Expand Down
Loading