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.

s3: increase timeout limit

chrislu5788bf2270c2
diff --git a/weed/command/s3.go b/weed/command/s3.go
index ee726fcecb..679a4ae455 100644
--- a/weed/command/s3.go
+++ b/weed/command/s3.go
@@ -192,7 +192,7 @@ func (s3opt *S3Options) startS3Server() bool {
httpS := &http.Server{Handler: router}
listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port)
- s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
+ s3ApiListener, err := util.NewListener(listenAddress, time.Duration(30)*time.Second)
if err != nil {
glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err)
}
diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go
index d78332395d..b06f540fb1 100644
--- a/weed/s3api/s3api_object_handlers.go
+++ b/weed/s3api/s3api_object_handlers.go
@@ -364,7 +364,9 @@ func passThroughResponse(proxyResponse *http.Response, w http.ResponseWriter) (s
statusCode = proxyResponse.StatusCode
}
w.WriteHeader(statusCode)
- io.Copy(w, proxyResponse.Body)
+ if n, err := io.Copy(w, proxyResponse.Body); err != nil {
+ glog.V(1).Infof("passthrough response read %d bytes: %v", n, err)
+ }
return statusCode
}
diff --git a/weed/util/http_util.go b/weed/util/http_util.go
index 7bd6758eb5..34765d68ef 100644
--- a/weed/util/http_util.go
+++ b/weed/util/http_util.go
@@ -392,11 +392,30 @@ func ReadUrlAsReaderCloser(fileUrl string, rangeHeader string) (io.ReadCloser, e
}
func CloseResponse(resp *http.Response) {
- io.Copy(io.Discard, resp.Body)
+ reader := &CountingReader{reader: resp.Body}
+ io.Copy(io.Discard, reader)
resp.Body.Close()
+ if reader.BytesRead > 0 {
+ glog.V(1).Infof("response leftover %d bytes", reader.BytesRead)
+ }
}
func CloseRequest(req *http.Request) {
- io.Copy(io.Discard, req.Body)
+ reader := &CountingReader{reader: req.Body}
+ io.Copy(io.Discard, reader)
req.Body.Close()
+ if reader.BytesRead > 0 {
+ glog.V(1).Infof("request leftover %d bytes", reader.BytesRead)
+ }
+}
+
+type CountingReader struct {
+ reader io.Reader
+ BytesRead int
+}
+
+func (r *CountingReader) Read(p []byte) (n int, err error) {
+ n, err = r.reader.Read(p)
+ r.BytesRead += n
+ return n, err
}