[BUG] BlobOpenWriteOptions.BufferSize ignored in BlockBlobClient.OpenWriteAsync #47782
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
Workflow: This issue is responsible by Azure service team.
Storage
Storage Service (Queues, Blobs, Files)
Library name and version
Azure.Storage.Blobs 12.23.0
Describe the bug
The documentation for
[BlobOpenWriteOptions.BufferSize](https://github.com/Azure/azure-sdk-for-net/blob/710a44d062b41c3e8a59ba8676618e939d2ce0c2/sdk/storage/Azure.Storage.Blobs/src/Models/BlobOpenWriteOptions.cs#L18-L22)
says the default buffer used is 4MB and the max is 4000MB. That bufferSize is passed to StorageWriteStream, where the actual buffer size is calculated to be[Math.Min(Constants.MB, bufferSize](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Common/src/Shared/StorageWriteStream.cs#L96)
.This is because PooledMemoryStream ends up using an ArrayPool to back the buffer, which has a max array size of type int (and Shared in reality has a max of 1024 * 1024) so the Math.Min makes sense. It should just be caught in ValidateBufferSize() rather than silently changing what was requested.
Expected behavior
Expected:
stream._buffer.MaxArraySize == stream._bufferSize == 1073741824
Actual behavior
stream._bufferSize == 1073741824
stream._buffer.MaxArraySize == 1048576
Reproduction Steps
Environment
No response
The text was updated successfully, but these errors were encountered: