Concurrency Control
Why not locks?
A lock server that every writer must go through before committing would work. It would also put back exactly the central bottleneck and single point of failure both formats exist to avoid. And it fits badly with writers that are short-lived Spark jobs, Flink tasks, or serverless functions that can die without releasing anything. So both formats take the other route: assume collisions are rare, do all the work up front without coordinating, and only pay a coordination cost on the rare occasion two writers actually collide.
- The writer reads the current version V — the
metadata.jsonpointer, or the head of_delta_log. - It builds its entire change on its own: new data files, new manifests or log actions. It holds no lock on anything.
- It tries one atomic operation: "make V+1 mine, but only if the current version is still V."
- It works → the commit is durable. It fails → re-read the new state, check whether the two changes really conflict, and if they don't, try again at V+2.
Iceberg: catalog-level compare-and-swap
From the Iceberg's metadata tree part: the catalog holds exactly one changeable pointer per table. Committing works like this:
1. Writer reads metadata.json v8, notes current-snapshot-id = S8
2. Writer writes new data files, new manifest(s), new manifest list,
and a new v9.metadata.json (all new files — nothing above is touched)
3. Writer asks the catalog: "swap the pointer to v9.metadata.json,
but ONLY IF it currently still points to v8.metadata.json"| Catalog | How the CAS is executed atomically |
|---|---|
| Hive Metastore | A database UPDATE with a WHERE clause checking the old value — one transaction on the MySQL or Postgres behind HMS |
| AWS Glue | A conditional UpdateTable call |
| REST catalog | An HTTP request that includes the metadata location you expect to still be current. The server does the check-and-swap itself, usually against a database underneath |
| JDBC catalog | UPDATE iceberg_tables SET metadata_location = ? WHERE table = ? AND metadata_location = ? — how many rows that updated tells you whether you won |
If the swap fails because someone else already moved the pointer, the writer re-reads the new metadata, checks whether its change really conflicts, and if it doesn't, rebuilds its manifest list and metadata.json on top of the new version and tries again. It gets commit.retry.num-retries attempts (default 4), waiting a bit longer between each.
What counts as a conflict, in Iceberg
Two commits hitting the same table don't automatically conflict. Iceberg looks at what each one actually did:
| Scenario | Conflict? | Why |
|---|---|---|
A appends to dt=01-01; B appends to dt=01-02 | No | Both only add files. The retry just puts A's new manifest list on top of B's. Adding files to a newer version is always safe. |
| A appends rows; B deletes or overwrites rows in the same partition | Depends | If A's new rows have nothing to do with the files B removed, the retry is safe. If B's overwrite covers rows A's operation was counting on, the retry fails and reports a conflict. |
Two MERGE INTO statements hitting the same keys | Yes | A real conflict. Once retries run out, one of them has to fail. |
That's why running many streaming appenders against one Iceberg table is normal and works well — appends retry cheaply — while many upserters hitting the same keys really do queue up and fight each other.
Delta Lake: atomic file creation, plus conflict checks
Same structure, just done at the log instead of the catalog:
1. Writer reads the table at version V (checkpoint + replay, §3)
2. Writer computes its add/remove actions offline
3. Writer attempts to write `_delta_log/{V+1}.json` using an
ATOMIC "put-if-absent" — succeeds only if that file doesn't already exist
4. On failure, read the actual V+1 commit, run conflict detection based on
the transaction's ISOLATION LEVEL, and if clear, retry at V+2Why "create only if absent" was the hard part
Delta's whole commit protocol depends on the storage layer offering one thing: "create this file, but only if it doesn't already exist," and only one caller can win. On HDFS that's easy, because rename is atomic. On S3 it didn't exist for years. A plain S3 PUT just overwrites whatever's there. Port the protocol to S3 naively and two writers can both see that version 11 is free, both write 11.json, and the loser's changes vanish from history with no error.
| Store | Put-if-absent solution |
|---|---|
| HDFS | The filesystem's rename is already atomic |
| S3, before 2024 | not available You needed an outside service to arbitrate — open-source Delta shipped a DynamoDB-based commit coordinator (S3DynamoDBLogStore), and Databricks' own platform used an internal commit service — or you allowed only one writer |
| S3, since Aug 2024 | built in S3 added conditional writes (If-None-Match: *), so create-if-absent works directly against S3 |
| ADLS / GCS | built in Conditional writes via ETags. Delta on Azure and GCP never needed the S3 workaround |
Worked example: two writers racing for the same filename
Both start from version 10. Writer A appends new rows to dt=01-02. Writer B deletes rows from dt=01-01 (a remove plus an add). Each works out its own actions after reading version 10, with no knowledge of the other.
"Create only if absent" means the PUT for 11.json goes through only if nothing exists at that exact key. Otherwise it's rejected — never overwritten, never merged. That one operation is all Delta needs, because two writers racing for the same filename can't both win.
Notice what B does not do when it retries: any real work. part-B.parquet is already written and still valid. B just re-states the same remove and add actions under a new version number. Had B been touching dt=01-02 instead, the overlap with A would have triggered a real conflict.
Iceberg's atomic step is a compare-and-swap on one database row. Delta's is creating one file that must not already exist. Different machinery, same guarantee.
How the DynamoDB commit coordinator worked (S3 before 2024)
Since S3 couldn't do conditional writes, S3DynamoDBLogStore let DynamoDB decide who won and used S3 only to hold bytes, then reconciled the two afterward:
Fixing up stragglers: S3 still had no conditional write, so a slow writer could overwrite 11.json with stale bytes after the real winner put theirs there. Readers protect against that by checking 11.json against the DynamoDB record and re-copying the right temp file if the two disagree. DynamoDB is the source of truth; whatever is in S3 gets corrected to match it.
The trick was never to make S3 conditional. It was to hand the decision to a store that already had that operation, and use S3 for bulk bytes plus a repair step.
Isolation levels — how Delta decides if a retry is safe
| Isolation level | Behavior |
|---|---|
| Serializable (strictest) | Any other commit landing on the same table counts as a possible conflict. Very safe, and the most retries |
| WriteSerializable default | Only a conflict if the two transactions touched the same files or partitions. An append from one writer and a targeted delete from another, in different partitions, both succeed |
WriteSerializable makes the same practical trade Iceberg does by looking at what each commit touched: don't make the whole table wait just because two writers hit it at the same time — only serialize the parts that actually overlap.
Side-by-side
| Iceberg | Delta Lake | |
|---|---|---|
| Where the atomic step happens | The catalog (HMS / Glue / REST / JDBC) — compare-and-swap on one pointer | The storage layer — create the next numbered JSON file, only if it doesn't exist |
| What counts as a conflict | Based on the operation: do the two commits touch the same files | Based on the isolation level: do the two transactions touch the same files or partitions |
| Historical weak spot | The catalog matters. One without a real compare-and-swap — a misconfigured HMS, something homegrown — breaks the whole guarantee | S3 had no conditional writes until 2024, so you needed a DynamoDB commit coordinator |
| How retries work | Rebuild the manifest list on the new metadata.json, try the swap again, limited number of attempts | Restate the actions under the new version number, try the create again, limited number of attempts |
The Invariants
- Guarantees: No version is ever half-visible: a reader gets version N complete, or doesn't see it at all. A commit that succeeds is final and won't be quietly overwritten by a writer that lost the race — as long as the atomic swap is actually implemented correctly for your storage backend.
- Does not guarantee: Neither promises your write will succeed when writers are competing. A writer that keeps losing can run out of retries and fail, and that's working as designed. Neither protects you from races in your own code before the commit either — two jobs both reading "current max ID" and both computing +1, for instance.