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.
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 ofjava.security.SecureRandom. That class provides a cryptographically-strong random number generator with non-deterministic output.uuidandblobNameas a sanity-check. Did you study your logs? Did you see duplicates there? Verify yourimportstatements, and change those variable names to avoid collisions.blobContainerClientandBlobClientboth thread-safe? I would guess you have some kind of thread-safety or cached-value problem.