Part 2 · Object storage · Chapter 3
S3 semantics: consistency, atomicity and cost
Exactly what an object store promises: a flat key space, sorted and paginated LIST, atomic single-object PUT, strong read-after-write since December 2020, no rename, conditional writes since 2024, and request rates that make file counts matter.
After this chapter you should be able to:
- State the S3 consistency model before and after December 2020, and what it still does not give you.
- Explain why rename is not atomic on S3 and what that broke.
- Use conditional writes (If-None-Match, If-Match) correctly, including the 409 and 404 cases.
- Reason about prefixes, request rates, throttling (503 Slow Down) and range reads.
Every table format in this book stores its data and its log as objects. Delta’s whole concurrency story (chapter 10) and Iceberg’s (chapter 17) are built on what an object store will and will not promise about those objects. This chapter pins those promises down for Amazon S3, from the S3 User Guide and API reference, and then shows what Delta’s S3 LogStore does with them.
AWS documentation is not versioned by commit, so these links point at the current pages. Delta links point to delta-io/delta at 25561a5.
Objects, keys and the flat namespace
A general purpose bucket is a map from a key (a UTF-8 string) to an object: bytes, plus metadata and an ETag. There are no directories. _delta_log/00000000000000000005.json is one key that happens to contain slashes. A “folder” in the console is a key prefix, and / is not special to S3 at all: the performance guide says so in as many words, and a LIST groups keys by / only when you pass it as the delimiter.[ListObjectsV2][limits]
Two consequences follow. A “directory” cannot be renamed, locked or created atomically, because it does not exist. And “list the files in this directory” is a query over the key space, with a cost that grows with the number of keys under the prefix.
Listing
ListObjectsV2 takes a Prefix, an optional Delimiter, a StartAfter key and a ContinuationToken. For general purpose buckets it returns keys in lexicographic order of their UTF-8 bytes, at most 1,000 per response. If there are more, IsTruncated is true and NextContinuationToken carries on; the token is “obfuscated and is not a real key”. With a delimiter, keys that share the next path segment are rolled up into one CommonPrefixes entry, and each such entry counts as one item toward the 1,000.[ListObjectsV2]
trips/data/ keys under one CommonPrefixes entry. Without the delimiter, the listing returns the three matching keys individually.[ListObjectsV2] Directory buckets (S3 Express One Zone) are different: their LIST results are not sorted, and they do not support StartAfter.[ListObjectsV2] Everything below assumes a general purpose bucket.
Byte order explains a detail every Delta user has seen. The log is 00000000000000000000.json, …01.json and so on, padded to 20 digits. Unpadded, 10.json would sort before 9.json. Padded, key order is version order, so the latest version is the last key in a listing, and finding “every commit after version 1,234” is a seek. Delta’s S3 LogStore can pass the start key as StartAfter, so S3 skips the older entries instead of the client listing the whole _delta_log/ prefix and filtering it. That option is delta.enableFastS3AListFrom, off by default:[src]
// BaseS3LogStore.listFromInternal, trimmed
if (fs instanceof LocalFileSystem || !enableFastListFrom) {
statuses = fs.listStatus(parentPath); // list the whole _delta_log/
} else {
statuses = S3LogStoreUtil.s3ListFromArray(fs, resolvedPath, parentPath); // StartAfter
}
return Arrays.stream(statuses)
.filter(s -> s.getPath().getName().compareTo(resolvedPath.getName()) >= 0)
.sorted(Comparator.comparing(a -> a.getPath().getName()))
.iterator();
[src] The final sort and filter mean the result is correct either way; the option only changes how many keys come over the wire.
Q1. In a general purpose bucket, what is the directory _delta_log/?
Q2. A bucket holds the keys log/9.json, log/10.json and log/11.json. In what order does ListObjectsV2 return them?
Q3. You ask for MaxKeys=5000. How many keys can one ListObjectsV2 response contain?
Q4. Why does Delta's fast listFrom for S3 pass StartAfter?
Consistency, then and now
The current model, from the User Guide:[consistency model]
- “Amazon S3 provides strong read-after-write consistency for PUT and DELETE requests of objects in your Amazon S3 bucket in all AWS Regions.” A GET, HEAD or LIST that starts after a successful PUT or DELETE sees its effect.
- “Updates to a single key are atomic.” A reader sees the old object or the new one, never a mix.
- “Amazon S3 does not support object locking for concurrent writers. If two PUT requests are simultaneously made to the same key, the request with the latest timestamp wins.”
- “Updates are key-based. There is no way to make atomic updates across keys.”
- Bucket configuration is the exception: it is eventually consistent. After enabling versioning, for example, the guide says to wait 15 minutes before writing.
The third and fourth points are the ones a table format cares about. Strong consistency means that once commit 5 is written, everyone who lists the log will see it. It does not stop two writers from both writing commit 5; both get 200 OK, and the later one silently replaces the earlier one. And it gives no way to change two objects together, which is why both formats funnel every commit through a single object: Delta’s N.json, Iceberg’s catalog pointer.
Strong consistency arrived in December 2020.[AWS What's New] Before that, S3 gave read-after-write consistency for new objects, but overwrites, deletes and LIST were eventually consistent: a listing right after a write could miss a new key or still show a deleted one, and a GET after an overwrite could return the old bytes for a while.[AWS What's New] Engines lived with this for years. EMR, for example, shipped “EMRFS consistent view”, which recorded the files a job wrote in a DynamoDB table and checked listings against it.[EMR consistent view] A Delta reader that listed _delta_log/ on old S3 could miss the newest commit and read a stale version; the newest commit it did see was always complete, because single-object writes were always atomic.
Q1. Today, a PUT of a new object returns 200. A LIST of its prefix starts right after. Is the object in the listing?
Q2. Does strong consistency let you update two keys atomically?
Q3. Two clusters PUT the same key at nearly the same time, without conditions. What happens?
Q4. Before December 2020, what could a Spark job see right after another job overwrote or deleted files?
Writes: PUT, multipart upload, copy
PUT writes a whole object. Since updates to a single key are atomic, a writer that crashes mid-upload leaves nothing behind that a reader can see: the old object, or no object, stays in place.[consistency model] This is the one storage property Delta’s LogStore contract asks for beyond mutual exclusion: if partial writes are visible, the implementation must say so, and an S3 LogStore says they are not.[src][src]
Multipart upload is how large objects (Parquet files of hundreds of MB) are written. CreateMultipartUpload returns an upload id; UploadPart sends numbered parts, in any order and in parallel; CompleteMultipartUpload lists the parts and assembles the object. Parts are 5 MiB to 5 GiB, except the last, which may be smaller; there are at most 10,000 parts; an object can be up to 48.8 TiB. AWS suggests considering multipart once objects reach 100 MB.[limits] Until completion, nothing is visible to GET or LIST, so the object appears atomically like a single PUT.
CopyObject copies an object server-side, atomically, up to 5 GB in one request; larger copies use UploadPartCopy within a multipart upload.[CopyObject] A copy is a new object with a new ETag at the destination, and by default it overwrites whatever is there.
Q1. A writer crashes in the middle of uploading a 200 MB PUT. What can readers see?
Q2. Which are true of multipart upload? (select all that apply)
Rename is two requests
HDFS has an atomic rename(src, dst) that fails if dst exists. Hadoop’s original output committers and the early Delta and Iceberg file-system schemes all used it: write to a temporary name, then rename into place, and let the rename decide who won.
A general purpose bucket offers no such operation. The S3A connector “mimics rename() by copying files and then deleting the originals”, and the Hadoop docs warn that rename-based commits on S3 risk “loss or corruption of generated data”.[Hadoop S3A committers] Copy-then-delete breaks rename’s two useful properties at once:
- It is not atomic. Between the copy and the delete, both keys exist. A crash between them leaves both.
- It is not exclusive. The copy overwrites
dstif it exists, so two writers renaming different temporary files to5.jsonboth succeed, and the later copy wins.
The second point is what matters for a commit protocol. Iceberg’s spec still describes the rename-based scheme for file-system tables, marks it deprecated, and calls it unsafe on object stores.[spec] Chapter 4 covers what replaced it.
Q1. Hadoop rename(tmp, 5.json) on S3A is a copy then a delete. What can another client see in between?
Conditional writes
Since August 2024, PutObject and CompleteMultipartUpload accept HTTP preconditions; If-Match followed in November 2024, and CopyObject takes them too.[document history][conditional writes] They need SigV4-signed requests. They give S3 the two primitives a commit protocol needs.
If-None-Match: * is put-if-absent. The write succeeds only if no object exists under the key, and otherwise fails with 412 Precondition Failed. The race between two such writers is decided at the end, not the start: “If multiple conditional writes or copies occur for the same object name, the first write operation to finish succeeds.”[conditional writes] A Delta writer can now create N.json with this header and treat 412 as “someone else committed version N”, which is exactly the FileAlreadyExistsException the LogStore contract asks for.[src]
If-Match: <etag> is compare-and-swap. Read an object and its ETag, then PUT a new version with If-Match set to that ETag. If anyone replaced the object in between, the ETag no longer matches and the write fails with 412. If the object does not exist, or was deleted, it fails with 404. This is the primitive for a mutable pointer, the shape of an Iceberg catalog’s “current metadata location”. If-Match also needs s3:GetObject permission, besides s3:PutObject.[conditional writes]
The edge cases are where implementations go wrong:[conditional writes]
| Situation | Response | What to do |
|---|---|---|
Key exists, If-None-Match: * | 412 | You lost. Re-read and retry at the next version. |
ETag changed, If-Match | 412 | You lost. Re-read and retry. |
No object, If-Match | 404 | The thing you meant to swap is gone. |
| A DELETE succeeds while the conditional write is in flight | 409 ConditionalRequestConflict (404 for If-Match) | For PutObject, retry. For CompleteMultipartUpload, start the upload again. |
| Another client has an in-progress multipart upload to the key | Ignored | “Conditional writes do not consider any in-progress multipart uploads.” Only completed objects count. |
A bucket policy can require them: the condition keys s3:if-none-match and s3:if-match deny unconditional writes, so no client can bypass the protocol by accident.[enforcing conditional writes] Conditional deletes followed in September 2025.[document history]
- LIST _delta_log/ → latest is 4.json. Both writers read the table at version 4 and decide the next commit is 00000000000000000005.json. LIST is strongly consistent today, so both see the same latest version. consistency model ↗
- LIST _delta_log/ → latest is 4.json. Nothing coordinates the two clusters. Each writer only knows what S3 told it.
- PUT 5.json (plain). Without a condition, S3 accepts every PUT. "If two PUT requests are simultaneously made to the same key, the request with the latest timestamp wins." consistency model ↗
- PUT 5.json (plain). B also gets 200. One of the two commits is now gone, and neither writer can tell.
- 200 OK.
- 200 OK (one commit silently lost). This is why a Delta table on S3 needed a single writer, or DynamoDB, before conditional writes.
- PUT 6.json If-None-Match: *. Now with a condition. The write succeeds only if no object with this key exists when the write finishes. conditional writes ↗
- PUT 6.json If-None-Match: *. "If multiple conditional writes or copies occur for the same object name, the first write operation to finish succeeds." conditional writes ↗
- 200 OK (A finished first).
- 412 Precondition Failed. B learns it lost. It re-reads 6.json, runs its conflict check (chapter 10), and tries 7.json. conditional writes ↗
Q1. Two writers PUT 6.json with If-None-Match: *. A starts first, B finishes first. Who wins?
Q2. You read pointer.json with ETag "e1" and PUT a new version with If-Match: "e1". Another writer replaced it first. What do you get?
Q3. A conditional CompleteMultipartUpload returns 409 ConditionalRequestConflict because a delete landed during the request. What must you do?
Q4. Writer A has an in-progress multipart upload to 7.json. Writer B does a PUT of 7.json with If-None-Match: *. What happens to B?
What the table formats need
Delta’s LogStore contract asks storage for two things: creating a file must fail with FileAlreadyExistsException if it exists (mutual exclusion), and a file must become visible all at once.[src] S3 always gave the second. The first is the hard part, and S3SingleDriverLogStore, the default S3 LogStore, gets it only inside one JVM:
// BaseS3LogStore.writeWithPathLock, trimmed
withPathLock(resolvedPath, () -> { // a lock shared by this JVM only
if (fs.exists(resolvedPath) && !overwrite)
throw new FileAlreadyExistsException(resolvedPath.toUri().toString());
CountingOutputStream stream = new CountingOutputStream(fs.create(resolvedPath, overwrite));
while (actions.hasNext()) stream.write((actions.next() + "\n").getBytes(UTF_8));
stream.close(); // the PUT completes here
});
[src]
[src]
Inside one driver the lock makes check-then-create safe. Across two clusters, each has its own lock, both exists() checks return false, and both PUTs succeed: the first half of the sequence diagram above. The comment on the lock says what closes that gap: “Conditional writes still provide mutual exclusion between independent drivers.”[src] Before 2024 the only way to get it was outside S3, with S3DynamoDBLogStore; chapter 4 walks through that design and the conditional-write path that replaces it.
Iceberg needs less from the store, because its commit is a swap in the catalog, not a file creation. Data files, manifests and metadata files all have unique names, so S3 only has to store them atomically and list nothing; the catalog (Hive, Glue, JDBC, REST, chapter 21) holds the pointer.[spec]
Q1. What does S3SingleDriverLogStore do to keep two writers from both creating 5.json?
Performance and cost model
S3 scales by key prefix. The guide documents “at least 3,500 PUT/COPY/POST/DELETE or 11,000 GET/HEAD requests per second per partitioned prefix”, and there is no limit on the number of prefixes, so ten prefixes can serve ten times that.[performance] While S3 is repartitioning for a rising load, it may answer 503 Slow Down; the SDKs retry with exponential backoff, and the guide’s example backs off 2 seconds, then 4.[guidelines] Hammering a few objects is its own problem: “sustained rates of over 5,000 requests per second to a small number of objects” can also cause 503s.[design patterns]
Three habits of lakehouse readers come straight from this model.
Range reads. A GET with Range: bytes=a-b returns 206 and just those bytes. A Parquet footer sits at the end of the file and says where each column chunk lives (chapter 5), so a reader does a small ranged GET for the footer and then ranged GETs for the column chunks the query needs, in parallel. The guide recommends exactly this, with ranges aligned to the part boundaries of a multipart object where possible; GET ?partNumber=N fetches one part.[design patterns]
Parallel connections. One connection has a bounded throughput, and S3 does not limit the number of connections, so engines read many objects, and many ranges of one object, at once.[guidelines]
File counts. Every GET, PUT and LIST page is a request, with a first-byte latency and a price. A scan of 100,000 one-megabyte files makes about 1,000 times as many GETs as a scan of 100 one-gigabyte files over the same bytes, and its table metadata has 1,000 times as many entries to plan with. This is the storage-level reason for compaction and target file sizes in later chapters.
Q1. What request rate does S3 document per partitioned prefix?
Q2. Why do Parquet readers use ranged GETs?
Q3. A table has 100,000 files of 1 MB. Compacted, it would be 100 files of 1 GB. What gets cheaper for a full scan?
Try it
Two clients share one bucket. Each PUT is split into Start and Finish, so you choose the interleaving.
- Leave both clients on “plain PUT”. Start PUT on A, Start PUT on B, Finish B, Finish A. Both return
200, but the bucket holds B’s body. B’s request started later, so it has the later timestamp and wins, even though A finished last. A’s commit is gone and A was told it succeeded. (S3 does not document which timestamp it compares; the simulator uses the request’s start.) - Reset, set both clients to “If-None-Match: *” and repeat. B finishes first and wins; A gets
412. - Reset, PUT once so the key exists, then set both clients to “If-Match: current ETag”, start both, and finish both. One
200, one412. - With an If-None-Match PUT in flight, press DELETE on the other client, then finish the PUT:
409. - Switch to “before Dec 2020”, PUT, PUT again with a different client, and GET: you may see the old body until you press “Let it settle”. LIST shows the snapshot too.
- Change the LIST prefix and the key (try
log/9.json,log/10.json) to see byte-order listing.
Client A
Client B
Requests · newest first
Try: Start PUT on A, Start PUT on B, Finish B, Finish A. Then Reset, set both to If-None-Match and do it again.
Bucket · what S3 holds now
| key | body | ETag |
|---|---|---|
| empty | ||
Consistency model ↗ · Conditional writes ↗ · ListObjectsV2 ↗
History
- 2006 Amazon S3 launches; overwrites, deletes and LIST are eventually consistent · AWS
- 2020-12 Strong read-after-write consistency for all requests, including LIST · AWS
- 2024-08-20 Conditional writes: If-None-Match on PutObject and CompleteMultipartUpload · AWS
- 2024-11-25 If-Match conditional writes, and bucket-policy condition keys to enforce them · AWS
- 2025-09-16 Conditional deletes · AWS
The exact dates for 2024 and 2025 come from the S3 User Guide’s document history. The launch and the consistency change are given to the year and month only.
Summary
- The key space is flat. LIST is sorted by UTF-8 bytes in general purpose buckets, at most 1,000 keys a page, and
StartAfteris a seek. Delta pads versions so key order is version order. - Since December 2020, PUT, DELETE and LIST are strongly consistent. A single-object write is atomic. Nothing spans two keys, and two plain PUTs to one key both “succeed”.
- There is no rename. Copy-then-delete is neither atomic nor exclusive, which is why rename-based commit schemes are unsafe on S3.
If-None-Match: *(put-if-absent) andIf-Match(compare-and-swap) make S3 a commit arbiter for one key. The first conditional write to finish wins; handle 412, 409 and 404.- Request rates are per prefix, every request has a cost, and readers use ranged GETs. File count, not just bytes, sets the cost of a scan.
Concepts in this chapter
Explained here
Primary sources
Review this chapter
This chapter has 19 quiz questions.