The Object-Store Commit
Concepts covered: Distributed Primitives
The commit protocol you already know assumes renaming a directory is one atomic metadata operation. Tasks write under _temporary, task commit renames each attempt directory, job commit renames the results into place, and _SUCCESS appears last. On a cluster filesystem such as HDFS each rename edits the namenode's metadata and finishes in milliseconds.
An object store has no directories and no rename. A path like /sales/ds=2024-03-14/part-00007.parquet is one key in a flat namespace, and the slashes are ordinary characters. Renaming means copying each object to a new key and deleting the old one, so a rename costs time in proportion to bytes, and renaming a directory becomes thousands of independent copies that can stop halfway.
What the rename turns into
| Commit step (algorithm v1) | On a cluster filesystem | On an object store |
|---|---|---|
| Task commit | Rename the attempt directory: one metadata edit | Copy and delete every file the task wrote |
| Job commit | Rename each task's output: metadata edits | Copy and delete every file again, issued by the driver |
| Crash mid-commit | Each rename is all or nothing | Some files moved, some not |
Put numbers on it. A job writes 1,000 files of 128MB each. Algorithm v1 copies that output twice, and the job-commit copies run from the driver. Assume the store copies 100MB/s per object and the driver works through files one at a time.
- 256GB
- 21 min
Algorithm v2 drops the second copy by having task commit move files straight into the destination. The job runs faster and loses its job-level guarantee: readers can see a half-finished job's output, and an attempt that fails mid-commit can leave some files in the destination with nothing recording them. On an object store, v1 is slow and v2 is unsafe.
Committers built for object stores
The replacement uses something object stores do offer: multipart upload. A client uploads an object's parts, and the object appears at its final key only when the client sends a completion request. Until then readers see nothing, and the completion is atomic per object.
- Task attempt (transform, executor)
- Open uploads (storage, object store)
- Pending-upload list (storage, cluster filesystem)
- Job commit (transform, driver)
- Visible files (consumer, readers)
- Task attempt -> Open uploads
- Task attempt -> Pending-upload list
- Pending-upload list -> Job commit
- Job commit -> Visible files
The staging and magic committers both build on this. The staging committer writes each task's output to local disk, starts the uploads at task commit without completing them, and saves the pending-upload list through the classic v1 committer on a cluster filesystem. The magic committer skips the local copy: the store client spots a special path inside the output directory and turns writes there into pending uploads at the final keys. Either way, job commit completes each upload with a metadata request instead of copying bytes, and an aborted job cancels its uploads before any reader saw them.
Fast job commit narrows the danger window without closing it: a driver that dies after completing 600 of 1,000 uploads leaves 600 files visible. The guarantee is per file, and _SUCCESS is still the only sign that a directory is whole.
Table formats commit a pointer
Table formats with a transaction log take the directory out of the question. Writers put data files under unique names, and no file belongs to the table until a commit lists it. The commit is one atomic metadata operation, appending log entry N or swapping the current-snapshot pointer, done as a conditional write that fails if another writer committed first.
- Rename-based commit
- Visibility follows which files sit in the directory
- Commit cost grows with bytes written
- A crash mid-commit can leave a partial directory
- Readers trust _SUCCESS by convention
- Log-based commit
- Visibility follows which files the log lists
- Commit cost is one metadata write
- A crash leaves unreferenced files no reader sees
- Readers resolve a snapshot and get all or nothing
A failed job in a table format leaves orphan files and an intact table, and a maintenance job later deletes files no snapshot references. Task retries are harmless for the same reason: only files reported by winning attempts reach the log.
A job of 2,000 tasks, each writing 1 file, runs with algorithm v2 on an object store. The driver crashes after 1,200 task commits. What does a reader listing the destination see?
- Nothing: v2 publishes files at job commit, which never ran
- All 2,000 files: the store finishes the remaining uploads itself
- Only _SUCCESS, because the destination is cleaned when the driver dies
- About 1,200 files and no _SUCCESS: a partial dataset
About this lesson
This section is part of the Fault Tolerance: Advanced lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.