Min-Soo Pipefeet
Min-Soo Pipefeet

Reputation: 2608

caveat of the read-after-write consistency for PUTS of new objects in a S3 bucket

From https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html :

Amazon S3 provides read-after-write consistency for PUTS of new objects in your S3 bucket in all regions with one caveat. The caveat is that if you make a HEAD or GET request to the key name (to find if the object exists) before creating the object, Amazon S3 provides eventual consistency for read-after-write.

I'm not sure if I understand the caveat correctly. Before creating the object: ok, I haven't yet created an object with the key K, therefore no object with the key K exists; I make a GET request to K... what does my request result to according to the explanation above?

I'm confused because the explanation tells about the eventual consistency for read-after-write. But there is no write so far.

Upvotes: 3

Views: 720

Answers (2)

Sanghyun Lee
Sanghyun Lee

Reputation: 23102

Update 2020-12-02 This whole discussion is now outdated. Amazon S3 provides strong read-after-write consistency for PUTs and DELETEs of objects in your Amazon S3 bucket in all AWS Regions.

Update I rewrote the answer after reading a comment in this blog post.

I believe this caveat is talking about this scenario

client 1: GET key_a  -->  this could return an object even this request was sent earlier.
client 2: PUT key_a

This could be possible in case the request of client 1 reached later than the PUT request to a node.

Upvotes: 1

guest
guest

Reputation: 637

This situation happens when you have a file to upload, but that file might already exist. So rather than overwrite the existing file, you do the following:

  1. Try to GET the file. It doesn't exist, so you get a 404 with No such key
  2. PUT the file.
  3. Try to GET the file immediately afterward (for whatever reason).

In this sequence, step #3 may or may not return the file. Eventually you can retrieve the file, but how long that takes from the time of upload depends on the internals of S3 (I could speculate on why that happens, but it would only be speculation).

Upvotes: 0

Related Questions