aboutsummaryrefslogtreecommitdiff
path: root/weed/server/filer_server_handlers.go
diff options
context:
space:
mode:
authorPatrick Schmidt <patrick.schmidt@innogames.com>2022-08-25 05:03:34 +0200
committerGitHub <noreply@github.com>2022-08-24 20:03:34 -0700
commit2930263dfdcc8891b313427b6160e70d5484bbc1 (patch)
tree278433a49a7712da0574a136b0cae70660c348b9 /weed/server/filer_server_handlers.go
parent7b424a54dc56c883a3e03894d924631a4ef7a94c (diff)
downloadseaweedfs-2930263dfdcc8891b313427b6160e70d5484bbc1.tar.xz
seaweedfs-2930263dfdcc8891b313427b6160e70d5484bbc1.zip
Fix race conditions during in-flight size checks (#3505)
Diffstat (limited to 'weed/server/filer_server_handlers.go')
-rw-r--r--weed/server/filer_server_handlers.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.go
index 4fb3c9609..153971f6e 100644
--- a/weed/server/filer_server_handlers.go
+++ b/weed/server/filer_server_handlers.go
@@ -2,14 +2,15 @@ package weed_server
import (
"errors"
- "github.com/seaweedfs/seaweedfs/weed/glog"
- "github.com/seaweedfs/seaweedfs/weed/security"
- "github.com/seaweedfs/seaweedfs/weed/util"
"net/http"
"strings"
"sync/atomic"
"time"
+ "github.com/seaweedfs/seaweedfs/weed/glog"
+ "github.com/seaweedfs/seaweedfs/weed/security"
+ "github.com/seaweedfs/seaweedfs/weed/util"
+
"github.com/seaweedfs/seaweedfs/weed/stats"
)
@@ -63,9 +64,11 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
// wait until in flight data is less than the limit
contentLength := getContentLength(r)
fs.inFlightDataLimitCond.L.Lock()
- for fs.option.ConcurrentUploadLimit != 0 && atomic.LoadInt64(&fs.inFlightDataSize) > fs.option.ConcurrentUploadLimit {
- glog.V(4).Infof("wait because inflight data %d > %d", fs.inFlightDataSize, fs.option.ConcurrentUploadLimit)
+ inFlightDataSize := atomic.LoadInt64(&fs.inFlightDataSize)
+ for fs.option.ConcurrentUploadLimit != 0 && inFlightDataSize > fs.option.ConcurrentUploadLimit {
+ glog.V(4).Infof("wait because inflight data %d > %d", inFlightDataSize, fs.option.ConcurrentUploadLimit)
fs.inFlightDataLimitCond.Wait()
+ inFlightDataSize = atomic.LoadInt64(&fs.inFlightDataSize)
}
fs.inFlightDataLimitCond.L.Unlock()
atomic.AddInt64(&fs.inFlightDataSize, contentLength)