2

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.

Min-Soo Pipefeet
  • 2,208
  • 4
  • 12
  • 31

2 Answers2

1

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.

Sanghyun Lee
  • 21,644
  • 19
  • 100
  • 126
0

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).

guest
  • 617
  • 4
  • 4
  • To expand on the OP's comment that *"there has been no write so far"* -- there necessarily has been, in one sense: there's been a write to an internal cache or index replica to indicate that a nonexistent object has been requested, thus creating an internal indication in S3 that changes existence of the object from "object existence unknown" to "object non-existence confirmed," a fact that can be internally "remembered" for some period of time -- typically very short but not guaranteed to be 0 -- and this internal indication is used when handling subsequent requests for the object. – Michael - sqlbot Apr 16 '19 at 19:11
  • 1
    Thanks for the answer but I don't think what you've written is correct. They say they provide read-after-write consistency for PUTS of new objects so [you should always be able to get an object at step 3](https://stackoverflow.com/questions/42957531/what-does-read-after-write-consistency-really-mean-on-new-object-put-in-s3). Please check out my answer. – Sanghyun Lee Dec 11 '19 at 14:23