From ebd0176daf671e05a81a290b74d5f378e96a303b Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Mon, 11 Mar 2024 15:19:34 -0700 Subject: [PATCH] downloader: add deadline --- renterd/downloader/downloader.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/renterd/downloader/downloader.go b/renterd/downloader/downloader.go index 94d7702..a04acd6 100644 --- a/renterd/downloader/downloader.go +++ b/renterd/downloader/downloader.go @@ -134,7 +134,7 @@ func (br *blockResponse) block(ctx context.Context, c cid.Cid) (blocks.Block, er func (bd *BlockDownloader) doDownloadTask(task *blockResponse, log *zap.Logger) { log = log.Named("doDownloadTask").With(zap.Stringer("cid", task.cid), zap.Stringer("priority", task.priority)) - blockBuf := bytes.NewBuffer(make([]byte, 0, 1<<20)) + blockBuf := bytes.NewBuffer(make([]byte, 0, 2<<20)) start := time.Now() bucket, key, err := bd.store.BlockLocation(task.cid) @@ -148,7 +148,10 @@ func (bd *BlockDownloader) doDownloadTask(task *blockResponse, log *zap.Logger) return } - err = bd.workerClient.DownloadObject(context.Background(), blockBuf, bucket, key, api.DownloadObjectOptions{}) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + err = bd.workerClient.DownloadObject(ctx, blockBuf, bucket, key, api.DownloadObjectOptions{}) if err != nil { if !format.IsNotFound(err) { log.Error("failed to download block", zap.Error(err))