Are append operations on an AppendBlob atomic?

2019-09-02 13:58发布

I am using append blob to store a large binary file. I've got the file in parts (every part is less than 4 MB) and append them to make it whole again. If an append operation fails during the process, are there any remains on the file from this failed append attempt? Or this append operation is atomic?

2条回答
手持菜刀,她持情操
2楼-- · 2019-09-02 14:38

With an Append Blob, as soon as you write a block to the blob it gets committed and changes the size of the blob. So in your scenario, let's say you've broken the source file in 10 parts and appending these parts. Let's further assume 1st - 4th part succeed, 5th part fails and then 6th - 10th part succeeds. In this case you will have a corrupt blob with parts 1-4 and 6-10. Because in an Append Blob, contents are always appended to the existing content of the blob, you would have no way to insert correct data for 5th part.

Considering this scenario, I would not recommend using Append Blobs. The use case for an Append Blob is definitely not this. I would recommend using Block Blob for this. With the Block Blob, you put 1st - 4th part and then 5th part fails then the whole upload operation will fail. With Block Blobs, Azure Storage keeps the uploaded yet uncommitted chunks for 14 days. So if you want to resume the upload from 5th part, you would get information about uncommitted chunks from Azure and then restart your upload from 5th part. Once the remaining parts are uploaded, you can instruct Azure to put these chunks together (using Put Block List operation) to create the blob.

查看更多
我只想做你的唯一
3楼-- · 2019-09-02 14:50

If the storage service returns a failure code, nothing remains from the failed attempt. This assumes 'attempt' means a single storage service call (ex append 4MB block).

查看更多
登录 后发表回答