azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[BUG] BlockBlobWriteStream does not implement IAsyncDisposable

Open klesta490 opened this issue 2 years ago • 9 comments
trafficstars

Library name and version

Azure.Storage.Blobs 12.13.1.0

Describe the bug

When using

await using (var stream = await blockBlob.OpenWriteAsync(true))

await stream.WriteAsync(new byte[4]);

Because of missing DisposeAsync implementation in BlockBlobWriteStream, generic implementation is called on Stream base class. This implementaiton calls sync Dispose() witch consequently calls Flush() - synchronous https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Common/src/Shared/StorageWriteStream.cs#L227

 public override void Flush()
            => FlushInternal(
                async: false,
                cancellationToken: default).EnsureCompleted();

and in this FlushInternal there is StagingBlock if needed. And then block ids are always commited. - synchronous https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/src/BlockBlobWriteStream.cs#L87

There is no way to avoid it, if I manually call FlushAsync() before DisposeAsync(), then in FlushInternal no blocks are staged, but I cannot avoid synchronous call for commiting block ids.

Am I missing something?

Expected behavior

DisposeAsync is properly implemented, so there is no sychronous call when using async API.

Actual behavior

DisposeAsync is not implemented/overriden, so when DisposeAsync is called, sychronous call from Stream base class to store block ids is done.

Reproduction Steps

await using (var stream = await blockBlob.OpenWriteAsync(true))

await stream.WriteAsync(new byte[4]);

Environment

No response

klesta490 avatar Apr 13 '23 13:04 klesta490

Thank you for your feedback. This has been routed to the support team for assistance.

github-actions[bot] avatar Apr 13 '23 13:04 github-actions[bot]

Any update?

klesta490 avatar Apr 17 '23 12:04 klesta490

Adding Service team to look into this.

navba-MSFT avatar Jul 14 '23 04:07 navba-MSFT

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

github-actions[bot] avatar Jul 14 '23 04:07 github-actions[bot]

Hello, any update? Is anyone there? @jsquire

klesta490 avatar Oct 02 '23 10:10 klesta490

@klesta490: I apologize that this has not been followed-up on. Unfortunately, I do not have direct insight here. We'll need the folks that own the Storage library to offer thoughts.

//cc: @seanmcc-msft, @amnguye //fyi: @schaabs

jsquire avatar Oct 02 '23 22:10 jsquire

Hello, is there any progress? @jsquire

mkopsa-quadient avatar Apr 30 '24 12:04 mkopsa-quadient

@mkopsa-quadient : The answer is the same as the one right above your comment. This is not an issue that I will have insight on and requires the owners of the issue to offer thoughts.

jsquire avatar Apr 30 '24 13:04 jsquire

OK. Can @seanmcc-msft or @amnguye answer?

mkopsa-quadient avatar May 03 '24 07:05 mkopsa-quadient