azure-sdk-for-go: Data corruption when uploading blob via `NewAppendBlobClient` =>`AppendBlock` API
Bug Report
We recently noticed that the data we upload to Azure Blob storage is not the same as the data we get when using AppendBlock API during the time when API is throttling our requests.
The problem is relativelly easy to replicate and can be summarised by the logs below:
When uploading large blob (32MiB) chunks (4MiB) in a loop, one of the chunk uploads fails with ```500 Operation timeout outbut theAppendBlock call does not return erorr so the upload continues. Later, when fetching uploaded blob for inspection using GetBlob, we get200stauts butInternalError` Status text and the corrupted file. The corruption is basically about the chunk that failed to upload being missing.
The code we are using is opensource and can be found here: https://gitlab.com/gitlab-org/container-registry/-/blob/a7581d9e743bba63e8318f304a799a09ae9e4580/registry/storage/driver/azure/v2/azure.go#L645
One of the tests that fails due to this issue: https://gitlab.com/gitlab-org/container-registry/-/blob/a7581d9e743bba63e8318f304a799a09ae9e4580/registry/storage/driver/testsuites/testsuites.go?page=2#L1428-1449
The internal issue where we track this issue and where you can potentially find more details is here: https://gitlab.com/gitlab-org/container-registry/-/issues/1470
- import path of package in question:
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob - SDK version: v1.6.0
- output of
go version1.23.2`
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (10 by maintainers)
For
Append Blobcase application has to rely onx-ms-blob-condition-appendpos. From backend if SDK receives a 5xx status code it will retry (default retry policy) and the previous operation was a success at backend, this retry will end up adding a duplicate block to the blob. Details on this field and usage can be found here.@jhendrixMSFT what you suggested seems to be only option as of now to protect against such accidental corruptions.
No, we have enough info to move forward on this.
I double-checked my findings with a simple script below and this may indeed be a duplicate block after all - apologies, I was counting in the wrong direction 😦
It is pretty late for me, I should probably call it a day for today 😃
@jhendrixMSFT Thank you for your reply and time.
Yes, we are using the default retry policy. I will work on enabling and reproducing the problem with client-side logs enabled tomorrow and try to provide you with more information.
By default, the retry policy will retry requests that fail with a 500 (see the docs here). It looks like you’re using the default behavior but let us know if I got that wrong.
If you have client-side logging enabled you should see the failed request and subsequent retry. So, assuming that the default behavior is in play, it would explain why you see a 500 server-side but not client side (assuming that the retried request succeeded). I looked through some of the links (thanks for providing detailed information, it’s super helpful) but didn’t see any client-side logs (let us know if I missed it). Would it be possible to reproduce the failure with client-side logging enabled?