mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(master): fix create dp timeout problem when create vol. #1000145610
Signed-off-by: zhumingze <zhumingze@oppo.com>
This commit is contained in:
parent
4373c0ae18
commit
15b24c6d0e
@ -99,7 +99,7 @@ const (
|
||||
cmdVolCreateUse = "create [VOLUME NAME] [USER ID]"
|
||||
cmdVolCreateShort = "Create a new volume"
|
||||
cmdVolDefaultMPCount = 3
|
||||
cmdVolDefaultDPCount = 10
|
||||
cmdVolDefaultDPCount = 3
|
||||
cmdVolDefaultDPSize = 120
|
||||
cmdVolDefaultCapacity = 10 // 100GB
|
||||
cmdVolDefaultZoneName = ""
|
||||
|
||||
@ -2972,7 +2972,6 @@ func (m *Server) createVol(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if vol, err = m.cluster.createVol(req); err != nil {
|
||||
|
||||
sendErrReply(w, r, newErrHTTPReply(err))
|
||||
return
|
||||
}
|
||||
|
||||
@ -3829,11 +3829,19 @@ func (c *Cluster) initDataPartitionsForCreateVol(vol *Vol, targetDpCount int, me
|
||||
return 0, err
|
||||
}
|
||||
|
||||
for retryCount := 0; dpCountOfMediaType < defaultInitDataPartitionCnt && retryCount < 3; retryCount++ {
|
||||
if targetDpCount < defaultInitDataPartitionCnt {
|
||||
targetDpCount = defaultInitDataPartitionCnt
|
||||
}
|
||||
|
||||
for retryCount := 0; dpCountOfMediaType < targetDpCount && retryCount < 3; retryCount++ {
|
||||
oldDpCountOfMediaType := dpCountOfMediaType
|
||||
|
||||
toCreateCount := targetDpCount - dpCountOfMediaType
|
||||
err = vol.initDataPartitions(c, toCreateCount, mediaType)
|
||||
if toCreateCount <= 0 {
|
||||
break
|
||||
}
|
||||
|
||||
err = c.batchCreateDataPartition(vol, toCreateCount, true, mediaType)
|
||||
if err != nil {
|
||||
log.LogErrorf("action[initDataPartitionsForCreateVol] vol(%v) mediaType(%v) retryCount(%v), init dataPartition error: %v",
|
||||
vol.Name, proto.MediaTypeString(mediaType), retryCount, err.Error())
|
||||
|
||||
@ -391,7 +391,7 @@ func TestCreateVolWithDpCount(t *testing.T) {
|
||||
// create volume and metaNode will create mp,sleep some time to wait cluster get latest meteNode info
|
||||
// cluster normal volume has 3 mps , total 3*3 =9 mp in metaNode
|
||||
|
||||
t.Run("dpCount != default count", func(t *testing.T) {
|
||||
t.Run("dpCount >= defaultInitDpCntForVolCreateCheck", func(t *testing.T) {
|
||||
req := &createVolReq{
|
||||
name: commonVolName + "001",
|
||||
owner: "cfs",
|
||||
@ -421,7 +421,8 @@ func TestCreateVolWithDpCount(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
dpCount := len(vol.dataPartitions.partitions)
|
||||
require.Equal(t, req.dpCount, dpCount)
|
||||
t.Logf("%v", dpCount)
|
||||
require.GreaterOrEqual(t, dpCount, defaultInitDataPartitionCnt)
|
||||
})
|
||||
|
||||
t.Run("dpCount > max count", func(t *testing.T) {
|
||||
|
||||
@ -218,7 +218,7 @@ const (
|
||||
intervalToCheckMissingReplica = 600
|
||||
intervalToWarnDataPartition = 600
|
||||
intervalToLoadDataPartition = 12 * 60 * 60
|
||||
defaultInitDataPartitionCnt = 10
|
||||
defaultInitDataPartitionCnt = 3
|
||||
maxInitDataPartitionCnt = 200
|
||||
volExpansionRatio = 0.1
|
||||
maxNumberOfDataPartitionsForExpansion = 100
|
||||
|
||||
@ -690,16 +690,6 @@ func (vol *Vol) initMetaPartitions(c *Cluster, count int) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (vol *Vol) initDataPartitions(c *Cluster, dpCount int, mediaType uint32) (err error) {
|
||||
if dpCount == 0 {
|
||||
dpCount = defaultInitDataPartitionCnt
|
||||
}
|
||||
|
||||
// initialize k data partitionMap at a time
|
||||
err = c.batchCreateDataPartition(vol, dpCount, true, mediaType)
|
||||
return
|
||||
}
|
||||
|
||||
func (vol *Vol) checkDataPartitions(c *Cluster) (cnt int) {
|
||||
shouldDpInhibitWriteByVolFull := vol.shouldInhibitWriteBySpaceFull()
|
||||
vol.SetReadOnlyForVolFull(shouldDpInhibitWriteByVolFull)
|
||||
@ -1232,7 +1222,7 @@ func (vol *Vol) autoCreateDataPartitions(c *Cluster) {
|
||||
if dpCntOfMediaType < minNumOfRWDataPartitions {
|
||||
log.LogWarnf("autoCreateDataPartitions: vol(%v) mediaType(%v) less than %v, alloc new partitions",
|
||||
vol.Name, proto.MediaTypeString(mediaType), minNumOfRWDataPartitions)
|
||||
c.batchCreateDataPartition(vol, minNumOfRWDataPartitions, false, mediaType)
|
||||
c.batchCreateDataPartition(vol, minNumOfRWDataPartitions-dpCntOfMediaType, false, mediaType)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1264,7 +1254,7 @@ func (vol *Vol) autoCreateDataPartitions(c *Cluster) {
|
||||
log.LogInfof("action[autoCreateDataPartitions] vol(%v) volStorageClass(%v), calculated createDpCount:%v",
|
||||
vol.Name, asc, createDpCount)
|
||||
} else if rwDpCountOfMediaType < minNumOfRWDataPartitions {
|
||||
createDpCount = minNumOfRWDataPartitions
|
||||
createDpCount = minNumOfRWDataPartitions - rwDpCountOfMediaType
|
||||
log.LogInfof("action[autoCreateDataPartitions] vol(%v) volStorageClass(%v), min createDpCount:%v",
|
||||
vol.Name, asc, createDpCount)
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user