mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Issue 51: Assign on empty cluster sometime fails under high concurrency
load Contributed by philoops
This commit is contained in:
parent
2637c9eac2
commit
54723c3713
|
@ -14,6 +14,7 @@ import (
|
|||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -48,6 +49,7 @@ var (
|
|||
|
||||
var topo *topology.Topology
|
||||
var vg *replication.VolumeGrowth
|
||||
var vgLock sync.Mutex
|
||||
|
||||
func dirLookupHandler(w http.ResponseWriter, r *http.Request) {
|
||||
vid := r.FormValue("volumeId")
|
||||
|
@ -97,9 +99,13 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
|
|||
writeJsonQuiet(w, r, map[string]string{"error": "No free volumes left!"})
|
||||
return
|
||||
} else {
|
||||
if _, err = vg.AutomaticGrowByType(rt, dataCenter, topo); err != nil {
|
||||
writeJsonQuiet(w, r, map[string]string{"error": "Cannot grow volume group! " + err.Error()})
|
||||
return
|
||||
vgLock.Lock()
|
||||
defer vgLock.Unlock()
|
||||
if topo.GetVolumeLayout(rt).GetActiveVolumeCount(dataCenter) <= 0 {
|
||||
if _, err = vg.AutomaticGrowByType(rt, dataCenter, topo); err != nil {
|
||||
writeJsonQuiet(w, r, map[string]string{"error": "Cannot grow volume group! " + err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue