aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/backend/s3_backend/s3_backend.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-09-04 22:23:28 -0700
committerchrislu <chris.lu@gmail.com>2022-09-04 22:23:28 -0700
commit39340f7e42ea3a2b68c60fe2e18dfb68638075aa (patch)
tree2644552b5a5bcd97fda1c5d81922dcc97ad99473 /weed/storage/backend/s3_backend/s3_backend.go
parent7c6324b114a3cfb26cf0130431376d3830ffcef1 (diff)
downloadseaweedfs-39340f7e42ea3a2b68c60fe2e18dfb68638075aa.tar.xz
seaweedfs-39340f7e42ea3a2b68c60fe2e18dfb68638075aa.zip
cloud tier: s3 consume all read response body
fix https://github.com/seaweedfs/seaweedfs/issues/3584
Diffstat (limited to 'weed/storage/backend/s3_backend/s3_backend.go')
-rw-r--r--weed/storage/backend/s3_backend/s3_backend.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/weed/storage/backend/s3_backend/s3_backend.go b/weed/storage/backend/s3_backend/s3_backend.go
index 01fcc1283..0b3db3c67 100644
--- a/weed/storage/backend/s3_backend/s3_backend.go
+++ b/weed/storage/backend/s3_backend/s3_backend.go
@@ -124,8 +124,6 @@ func (s3backendStorageFile S3BackendStorageFile) ReadAt(p []byte, off int64) (n
bytesRange := fmt.Sprintf("bytes=%d-%d", off, off+int64(len(p))-1)
- // glog.V(0).Infof("read %s %s", s3backendStorageFile.key, bytesRange)
-
getObjectOutput, getObjectErr := s3backendStorageFile.backendStorage.conn.GetObject(&s3.GetObjectInput{
Bucket: &s3backendStorageFile.backendStorage.bucket,
Key: &s3backendStorageFile.key,
@@ -137,13 +135,16 @@ func (s3backendStorageFile S3BackendStorageFile) ReadAt(p []byte, off int64) (n
}
defer getObjectOutput.Body.Close()
- glog.V(4).Infof("read %s %s", s3backendStorageFile.key, bytesRange)
- glog.V(4).Infof("content range: %s, contentLength: %d", *getObjectOutput.ContentRange, *getObjectOutput.ContentLength)
+ // glog.V(3).Infof("read %s %s", s3backendStorageFile.key, bytesRange)
+ // glog.V(3).Infof("content range: %s, contentLength: %d", *getObjectOutput.ContentRange, *getObjectOutput.ContentLength)
+ var readCount int
for {
- if n, err = getObjectOutput.Body.Read(p); err == nil && n < len(p) {
- p = p[n:]
- } else {
+ p = p[readCount:]
+ readCount, err = getObjectOutput.Body.Read(p)
+ n += readCount
+
+ if err != nil {
break
}
}