Skip to content

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.

fix avoid lock error

Chris Luf2cd753bf9dd
diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.go
index 0389e1e185..118646a040 100644
--- a/weed/server/filer_server_handlers.go
+++ b/weed/server/filer_server_handlers.go
@@ -58,8 +58,8 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
glog.V(4).Infof("wait because inflight data %d > %d", fs.inFlightDataSize, fs.option.ConcurrentUploadLimit)
fs.inFlightDataLimitCond.Wait()
}
- atomic.AddInt64(&fs.inFlightDataSize, contentLength)
fs.inFlightDataLimitCond.L.Unlock()
+ atomic.AddInt64(&fs.inFlightDataSize, contentLength)
defer func() {
atomic.AddInt64(&fs.inFlightDataSize, -contentLength)
fs.inFlightDataLimitCond.Signal()
diff --git a/weed/server/volume_server_handlers.go b/weed/server/volume_server_handlers.go
index ed7807bb85..ff2eccc111 100644
--- a/weed/server/volume_server_handlers.go
+++ b/weed/server/volume_server_handlers.go
@@ -42,6 +42,7 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
glog.V(4).Infof("wait because inflight download data %d > %d", vs.inFlightDownloadDataSize, vs.concurrentDownloadLimit)
vs.inFlightDownloadDataLimitCond.Wait()
}
+ vs.inFlightDownloadDataLimitCond.L.Unlock()
vs.GetOrHeadHandler(w, r)
case "DELETE":
stats.DeleteRequest()
@@ -55,8 +56,8 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
glog.V(4).Infof("wait because inflight upload data %d > %d", vs.inFlightUploadDataSize, vs.concurrentUploadLimit)
vs.inFlightUploadDataLimitCond.Wait()
}
- atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength)
vs.inFlightUploadDataLimitCond.L.Unlock()
+ atomic.AddInt64(&vs.inFlightUploadDataSize, contentLength)
defer func() {
atomic.AddInt64(&vs.inFlightUploadDataSize, -contentLength)
vs.inFlightUploadDataLimitCond.Signal()
@@ -92,11 +93,14 @@ func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Req
w.Header().Set("Access-Control-Allow-Credentials", "true")
}
switch r.Method {
- case "GET":
- stats.ReadRequest()
- vs.GetOrHeadHandler(w, r)
- case "HEAD":
+ case "GET", "HEAD":
stats.ReadRequest()
+ vs.inFlightDownloadDataLimitCond.L.Lock()
+ for vs.concurrentDownloadLimit != 0 && atomic.LoadInt64(&vs.inFlightDownloadDataSize) > vs.concurrentDownloadLimit {
+ glog.V(4).Infof("wait because inflight download data %d > %d", vs.inFlightDownloadDataSize, vs.concurrentDownloadLimit)
+ vs.inFlightDownloadDataLimitCond.Wait()
+ }
+ vs.inFlightDownloadDataLimitCond.L.Unlock()
vs.GetOrHeadHandler(w, r)
case "OPTIONS":
stats.ReadRequest()
diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go
index ae3c0b53f7..8602b08548 100644
--- a/weed/server/volume_server_handlers_read.go
+++ b/weed/server/volume_server_handlers_read.go
@@ -129,7 +129,6 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
onReadSizeFn := func(size types.Size) {
needleSize = size
atomic.AddInt64(&vs.inFlightDownloadDataSize, int64(needleSize))
- vs.inFlightDownloadDataLimitCond.L.Unlock()
}
if hasVolume {
count, err = vs.store.ReadVolumeNeedle(volumeId, n, readOption, onReadSizeFn)