How to list / delete uncommitted blob blocks, to avoid: "The uncommitted block count cannot exceed the maximum limit of 100,000 blocks."

Slavomir 5 Reputation points
2023-06-07T09:31:50.95+00:00

I am uploading files to azure blob storage (~1.4 GB) via Java SDK using com.azure.storage.blob.specialized.BlockBlobClient. In some situation my program was terminated before committing the uploaded blobs (application had a short timeout before interrupting). As this happened for a lot of files, it seems I have reached near the limit of 100 000 uncommitted blocks. Now when I try to upload such a file again, it fails with:

com.azure.storage.blob.models.BlobStorageException: Status code 409, "<?xml version="1.0" encoding="utf-8"?<Error><Code>BlockCountExceedsLimit</Code><Message>The uncommitted block count cannot exceed the maximum limit of 100,000 blocks.

I found this troubleshooting page related to my issue: https://learn.microsoft.com/en-us/troubleshoot/azure/general/invalid-blob-or-block-content-or-invalid-block-list

"Solution 1" Waiting 7 days, does not sound serious. It is not a real option for me.

Solution 2 : ... In my case I don't know what is "the same blob name". I lost the information which blobs uploads were interrupted. So this solution seems not applicable to me. Is there any way how to figure them out?

Solution 3 : I tried to get uncommitted blocks but again to get the uncommitted block list I need first to know the original blob name. Something like: containerClient.getBlobClient(<the_name>).getBlockBlobClient()..listBlocks(BlockListType.UNCOMMITTED).getUncommittedBlocks();

Is that correct? How can I take the names of the blobs with uncommitted blocks?

I would like to delete those uncommitted blocks. But I cannot reach them. Is there a way to see them form the Azure portal, in the storage browser? Maybe to filter by blobs having uncommitted blocks?

Best regards,

Slavomir

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Slavomir Grigorov 0 Reputation points
    2023-06-12T10:59:41.2066667+00:00

    I found a bug in the upload code that in deed caused much small blocks to be uploaded, therefore too many blocks were created. Now it is fixed and the upload works.

    If I will have some time I will have time I will investigate the procedure for detecting uncommitted blocks.

    Thanks and sorry for the confusion.


  2. KarishmaTiwari-MSFT 20,772 Reputation points Microsoft Employee Moderator
    2023-06-13T00:41:01.69+00:00

    @Slavomir I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer. Accepted answers show up at the top, resulting in improved discoverability for others.

    Cx shared -

    Issue: "I received the error - 'The uncommitted block count cannot exceed the maximum limit of 100,000 blocks', while uploading files to Azure Blob Storage. How can I find and delete the uncommitted blocks to resolve this?"

    Cause: I found a bug in my upload code that indeed caused much small blocks to be uploaded, therefore too many blocks were created. Now it is fixed, and the upload works.

    Suggested approach:
    A way to find identify blobs with uncommitted blocks is to try listing all the blobs in container using https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-list-java#use-a-flat-listing and
    then loop them through to identify blobs with uncommitted blocks using containerClient.getBlobClient(<the_name>).getBlockBlobClient().listBlocks(BlockListType.UNCOMMITTED).getUncommittedBlocks();

    If your issue remains unresolved or have further questions, please let us know in the comments how we can assist. We are here to help you and strive to make your experience better and greatly value your feedback.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.