From 4977a5b42dae745e50998913e7d9c901b49dc9b3 Mon Sep 17 00:00:00 2001 From: Mohit Sharma <65536214+mohsha-msft@users.noreply.github.com> Date: Tue, 17 Aug 2021 23:58:25 +0530 Subject: [PATCH] fix: chunkwriter hangs on cancel (#239) * fix: chunkwriter hangs on cancel * fix: chunkwriter hangs on cancel Co-authored-by: David Gustafson --- azblob/chunkwriting_test.go | 9 +++++++++ azblob/url_blob.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/azblob/chunkwriting_test.go b/azblob/chunkwriting_test.go index 1190d89..258cd7e 100644 --- a/azblob/chunkwriting_test.go +++ b/azblob/chunkwriting_test.go @@ -40,6 +40,8 @@ func newFakeBlockWriter() *fakeBlockWriter { func (f *fakeBlockWriter) StageBlock(ctx context.Context, blockID string, r io.ReadSeeker, cond LeaseAccessConditions, md5 []byte, cpk ClientProvidedKeyOptions) (*BlockBlobStageBlockResponse, error) { n := atomic.AddInt32(&f.block, 1) if n == f.errOnBlock { + // simulate activity + time.Sleep(100 * time.Millisecond) return nil, io.ErrNoProgress } @@ -220,6 +222,13 @@ func TestCopyFromReader(t *testing.T) { ctx: context.Background(), fileSize: _1MiB + 500*1024, }, + { + desc: "Send file(12 MiB) with default UploadStreamToBlockBlobOptions and a write error", + ctx: context.Background(), + fileSize: 12 * _1MiB, + uploadErr: true, + err: true, + }, { desc: "Send file(1.5 MiB) with 2 writers", ctx: context.Background(), diff --git a/azblob/url_blob.go b/azblob/url_blob.go index 434e8ba..d638bd5 100644 --- a/azblob/url_blob.go +++ b/azblob/url_blob.go @@ -314,7 +314,7 @@ func (b BlobURL) StartCopyFromURL(ctx context.Context, source url.URL, metadata nil, // immutability policy nil, BlobImmutabilityPolicyModeNone, nil, - ) + ) } // AbortCopyFromURL stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.