Are append operations on an AppendBlob atomic?

試著忘記壹切 提交于 2020-01-06 19:58:30

问题


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?


回答1:


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).




回答2:


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.



来源:https://stackoverflow.com/questions/35293815/are-append-operations-on-an-appendblob-atomic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!