Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

storj: fix "uplink: too many requests" errors when uploading to the same file

Nick Craig-Wood4b4198522dc5
diff --git a/backend/storj/fs.go b/backend/storj/fs.go
index cd36db6f2..6774cc949 100644
--- a/backend/storj/fs.go
+++ b/backend/storj/fs.go
@@ -589,6 +589,14 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
return nil, err
}
err = fserrors.RetryError(errors.New("bucket was not available, now created, the upload must be retried"))
+ } else if errors.Is(err, uplink.ErrTooManyRequests) {
+ // Storj has a rate limit of 1 per second of uploading to the same file.
+ // This produces ErrTooManyRequests here, so we wait 1 second and retry.
+ //
+ // See: https://github.com/storj/uplink/issues/149
+ fs.Debugf(f, "uploading too fast - sleeping for 1 second: %v", err)
+ time.Sleep(time.Second)
+ err = fserrors.RetryError(err)
}
return nil, err
}