SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
reduce the scope of inFlightUploadDataLimitCond lock
liubaojiangf0ee3e6f2129
diff --git a/weed/server/volume_server_handlers.go b/weed/server/volume_server_handlers.goindex aa231e650a..7e4c11fed2 100644--- a/weed/server/volume_server_handlers.go+++ b/weed/server/volume_server_handlers.go@@ -58,31 +58,27 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Requecase "PUT", "POST":contentLength := getContentLength(r)- startTime := time.Now()- vs.inFlightUploadDataLimitCond.L.Lock()// exclude the replication from the concurrentUploadLimitMBif r.URL.Query().Get("type") != "replicate" {+ startTime := time.Now()+ vs.inFlightUploadDataLimitCond.L.Lock()for vs.concurrentUploadLimit != 0 && vs.inFlightUploadDataSize > vs.concurrentUploadLimit {- //wait timeout+ //wait timeout checkif startTime.Add(vs.inflightUploadDataTimeout).Before(time.Now()) {- err := fmt.Errorf("reject because inflight upload data %d > %d, and wait timeout", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)vs.inFlightUploadDataLimitCond.L.Unlock()+ err := fmt.Errorf("reject because inflight upload data %d > %d, and wait timeout", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)glog.V(1).Infof("too many requests: %v", err)writeJsonError(w, r, http.StatusTooManyRequests, err)return}-glog.V(4).Infof("wait because inflight upload data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)vs.inFlightUploadDataLimitCond.Wait()}+ vs.inFlightUploadDataLimitCond.L.Unlock()}- vs.inFlightUploadDataSize += contentLength- vs.inFlightUploadDataLimitCond.L.Unlock()-+ atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength)defer func() {- vs.inFlightUploadDataLimitCond.L.Lock()- vs.inFlightUploadDataSize -= contentLength- vs.inFlightUploadDataLimitCond.L.Unlock()+ atomic.AddInt64(&vs.inFlightUploadDataSize, -contentLength)vs.inFlightUploadDataLimitCond.Signal()}()