1

During performance test we got some error from Azure Storage saying that

com.azure.storage.blob.models.BlobStorageException: Status code 409, "BlobAlreadyExistsThe specified blob already exists. RequestId:53c64237-701e-0086-6766-52cc7f000000

The obvious reason would be that we want to use the same id to upload the blob to Azure.
However what we have is

@Override
public String storeQuote(final JsonNode quote) {
    final String uuid = UUID.randomUUID().toString();
    try {
        final String blobName = BLOB_PREFIX + uuid;

        LOGGER.debug("Uploading content to blob[{}].", blobName);
        BlobClient blobClient = blobContainerClient.getBlobClient(blobName);
        blobClient.upload(BinaryData.fromObject(quote));
        LOGGER.debug("Upload was successful to blob [{}].", blobName);

        return uuid;
    }
    catch (Exception e) {
        throw new AzureBlogStorageErrorException("Error occurred when stored the quote in to Azure Blob Storage!", e);
    }
}

I can hardly imagine that we had 10+ times UUID collision in 1-2 hours performance test (I am just joking, obviously it can't happen or I am just very-very-... unlucky).

Any idea please what the issue can be please?

//////////////////////// question 1 ////////////////////////
I haven't set any retry mechanism, can this problem be caused by that? Is there a default retry if nothing is set? As far as I know there isn't but I am not 100% sure.

4
  • No, UUID.randomUUID() is not generating duplicates (unless you went out of your way to register a faulty security Provider); something else is going on. See the source code in OpenJDK. That class is implemented with no-arg constructor of java.security.SecureRandom. That class provides a cryptographically-strong random number generator with non-deterministic output. Commented Nov 13 at 4:21
  • Thanks for the reply. Yes, that was my understanding but as per my code above I am not sure what the root cause is. As I know there isn't a retry working when Azure Storage is called, at least I haven't set anything. I wouldn't want to add a silly code to generate a new UUID and upload again when this 409 error is retrieved. It would be good to find the root cause. However I might need to do that... Commented Nov 13 at 9:31
  • Start with logging the value of both uuid and blobName as a sanity-check. Did you study your logs? Did you see duplicates there? Verify your import statements, and change those variable names to avoid collisions. Commented Nov 13 at 17:49
  • Also, is your code multithreaded? Are blobContainerClient and BlobClient both thread-safe? I would guess you have some kind of thread-safety or cached-value problem. Commented Nov 13 at 17:54

1 Answer 1

0

Azure Storage SDK does, indeed, have a default retry mechanism built in. Most likely, the issue you're running into stems from partially completed uploads.

Since you're performance testing, the most likely scenario is that the upload is creating the file in your storage container, but due to high loads, the success response isn't being received by the client. Thus, the client will retry the upload using the same UUID.

In order to mitigate the issue you're going to want to use the BlobServiceClientBuilder.retryOptions() method to setup your retries. You can find documentation regarding the different options you can work with here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.