How can it be possible to implement in an application logic a way to prevent duplicate keys given the eventual consistency nature of S3.
So one way to check if a key exists is:
public boolean exists(String path, String name) {
try {
s3.getObjectMetadata(bucket, getS3Path(path) + name);
} catch(AmazonServiceException e) {
return false;
}
return true;
}
Is there a guarantee that when we gate our application logic with this, it will always return whether the key exists or not given, again the eventual consistency of S3? Let's say two requests came with both the exact same key/path would one get the response that it exists (e.g. by exists() == true
) or both will be stored but just in different versions?
I would like to point out that I am using S3 as document storage (similar to a JSON storage)
Using other "S3-Compatible" like Wasabi solves this problem as stated in this article: