Part 4 · Delta Lake protocol · Chapter 14
Catalog-managed tables and coordinated commits
When the catalog, not the filesystem, decides which commit is version v: proposed, staged, inline, ratified and published commits, the three commit options, how readers combine the catalog with a LIST, and what the Spark connector does differently.
After this chapter you should be able to:
- Define each commit type in the catalog-managed spec and say which one proves a version exists.
- Walk through the three commit options, the ratification rules and the publishing flow.
- Build a snapshot from a catalog response plus a directory listing, including which files to ignore.
- Explain why maintenance, timestamps and table discovery change on catalog-managed tables.
In chapter 10 a commit was a PUT-if-absent of <v>.json: whoever created the file first won version v, and the filesystem was the referee. That design has no place to hang anything that is not a file. A catalog can’t enforce a constraint at commit time, can’t commit two tables together, and can’t even be sure a table it governs isn’t being written behind its back. The catalogManaged feature moves the referee. With it enabled, “the catalog that manages the table becomes the source of truth for whether a given commit attempt succeeded.”[PROTOCOL]
All links are pinned to delta-io/delta commit 25561a5.
Why the catalog decides
The spec defines only the Delta side of the contract: what must be atomic, what readers must ask for, what goes in _delta_log, and when. The Delta client and the catalog “are otherwise free to define their own APIs and protocols for communication with each other.” The catalog may be a server (Unity Catalog), a database, or even client-side code over a filesystem.[PROTOCOL]
The feature is also a fence. Filesystem access to catalog-managed tables “is not supported”. The feature exists “to warn filesystem-based readers” and “to block filesystem-based writers who could otherwise corrupt both the table and the catalog”. It is a reader-writer feature: reader 3, writer 7, and catalogManaged in both lists.[PROTOCOL] An old client that doesn’t know the name refuses the table, as chapter 12 described.
The catalog must offer two capabilities: atomically commit version v with a given set of actions, and return recent ratified commits plus the latest ratified version. It is encouraged to also return the latest protocol and metaData, so a client can plan a query without replaying the log.[PROTOCOL]
Q1. On a table with catalogManaged active, what decides whether a commit attempt for version v succeeded?
Q2. Why is catalogManaged a reader-writer feature, not writer-only?
Commit types
A commit is the same set of actions as a Delta file. Only where it is stored, and who has accepted it, differ.[PROTOCOL]
| Type | Stored as | Meaning |
|---|---|---|
| Proposed | staged or inline | A client wants it to be version v. It will be ratified or rejected. |
| Staged | _delta_log/_staged_commits/<v>.<uuid>.json | Same content and format as a published file. Its existence alone means nothing: it “might correspond to a failed or in-progress commit attempt.” |
| Inline | inside the catalog | The content was sent to the catalog, and nothing was written to the log. |
| Ratified | catalog keeps the staged file’s location, or the inline content | The catalog decided this proposal won version v. It must be kept until published. |
| Published | _delta_log/<v>.json | A ratified commit copied into the log as a normal Delta file. |
Two consequences follow:
- A published file is proof. “The existence of a
<v>.jsonfile proves that the corresponding versionvis ratified, regardless of whether the table is catalog-managed or filesystem-based.” The catalog does not need to keep published commits. - A staged file is not proof. Only the catalog knows which of the staged files for a version won. A writer that lost the race leaves its staged file behind, and readers must ignore it.
The Delta client builds the actions and runs any LIST. The catalog client is the catalog’s client-side code: it stages or publishes commits and talks to the catalog server, if there is one. The Delta client defines the API that catalog clients target.[PROTOCOL]
Q1. A reader finds _delta_log/_staged_commits/00000000000000000010.<uuid>.json. What does that tell it?
Q2. Which file, by itself, proves that version v is ratified?
Q3. What may a catalog store for a ratified commit that is not yet published? (select all that apply)
Commit protocol
The Delta client hands the actions to the catalog client, which picks one of three options:[PROTOCOL]
- Staged. Write the actions to a staged commit file (likely client-side), then ratify it by atomically recording that the file is version
v(likely server-side). - Inline. Send the content to the catalog, which atomically records it as version
v. - PUT-if-absent. Ratify and publish at once by atomically writing
<v>.json. The commit “will be considered to have succeeded as soon as the file becomes visible in the filesystem, regardless of when or whether the catalog is made aware”. The catalog need not store it.
Option 3 is the chapter 10 protocol with a catalog in charge of it. Options 1 and 2 are new: the catalog’s atomic record is the commit point, not the filesystem.
Two rules make the catalog’s sequence of versions a log:
- A catalog “must not ratify version
vuntil it has ratified versionv - 1, and it must ratify versionvat most once.” Versions stay dense and unique without the filesystem’s help. - It must store ratified commits (staged locations or inline content) and serve them to readers until they are published.
Conflicts. A client that proposes a version someone else already won gets a conflict. The spec encourages an API where a failed commit returns the latest ratified commits, so the client can run the chapter 10 conflict check and retry at the next version without another round trip. The Spark connector’s test coordinator, InMemoryCommitCoordinator.addToMap, shows the shape. It expects exactly latest + 1. A lower version throws CommitFailedException(retryable = true, conflict = true). A higher one throws with both flags false, because a gap means the client is confused, not that it lost a race. (The very first commit to a table the coordinator has never seen is accepted at any version.)[src]
// InMemoryCommitCoordinator.addToMap, trimmed
val expectedVersion = tableData.maxCommitVersion + 1
if (commitVersion != expectedVersion && tableData.maxCommitVersion != -1) {
throw new JCommitFailedException(
commitVersion < expectedVersion, // retryable
commitVersion < expectedVersion, // conflict
s"Commit version $commitVersion is not valid. Expected version: $expectedVersion.")
}
val commit = new JCommit(commitVersion, commitFile, commitTimestamp)
tableData.commitsMap(commitVersion) = commit
tableData.updateLastRatifiedCommit(commitVersion)
src/sim/delta/catalog.ts implements ratify the same way, and its tests pin both error flavors.
Q1. Which are commit options in the spec's commit protocol? (select all that apply)
Q2. With option 3 (PUT-if-absent), when has the commit succeeded?
Q3. Which rules bind the catalog when ratifying? (select all that apply)
Q4. In the Spark connector's InMemoryCommitCoordinator (latest ratified = 8), what happens to a commit for version 10?
Reading a catalog-managed table
A ratified commit “is not discoverable through filesystem operations until it is published,” so LIST alone can miss the newest versions.[PROTOCOL] The catalog must return the latest ratified version, which is authoritative, and the ratified commits it still stores. The Delta client must get this “as part of the standard table resolution process performed at query planning time”. The spec’s sample API is getRatifiedCommits(startVersion, endVersion), which returns a contiguous, ascending list of commits plus the latest version.[PROTOCOL]
The read algorithm is then:[PROTOCOL]
- Ask the catalog for ratified commits and the latest version
L. - If that can’t complete a snapshot, LIST
_delta_logfor published files. - Where a version is both returned by the catalog and published, use the catalog’s copy.
- Ignore any file with a version above
L. - Pick a checkpoint and deltas as in chapter 11, with the catalog’s commits filling the top of the log.
- Catalog gives latest version 9 Versions 8 and 9 are ratified. They may still be absent from the directory listing.
- List for older history Use a published checkpoint and any published commits needed to fill the gap.
- Load snapshot 9 Prefer the catalog on overlap. Ignore any listed version above 9.
The spec’s own example has this listing and catalog state:
00000000000000000000.json
00000000000000000001.json
00000000000000000002.checkpoint.parquet
00000000000000000002.json
00000000000000000003.00000000000000000005.compacted.json
00000000000000000003.json … 00000000000000000007.json
_staged_commits/00000000000000000007.016ae953-….json // ratified and published
_staged_commits/00000000000000000008.7d17ac10-….json // ratified
_staged_commits/00000000000000000008.b91807ba-….json // rejected
_staged_commits/00000000000000000010.0f707846-….json // not yet ratified
_staged_commits/00000000000000000010.7a980438-….json // partial file
catalog: { 7 -> 7.016ae953….json, 8 -> 8.7d17ac10….json, 9 -> <inline> }, latest = 9
The catalog doesn’t know 7 was published (“perhaps the response from the filesystem was dropped”), 9 is inline, and neither staged 10 was ratified. The snapshot is version 9. It starts from checkpoint 2, uses the compacted range 3 to 5 and published 6, and takes 7, 8 and 9 from the catalog. The rejected staged 8 and both staged 10s are never read. The simulator’s first test reproduces exactly this plan.
Rule 4 is what makes the fence work for readers. If a filesystem writer bypasses the catalog and PUTs 10.json, the file is ignored because the catalog says the latest version is 9. Rule 3 makes publishing safe to retry: a published copy and the catalog’s copy have identical content, but the catalog’s is the one readers are required to trust.
Q1. Published: 0–7 with a checkpoint at 2. Catalog: {7: staged, 8: staged, 9: inline}, latest 9. Staged files also exist for a rejected 8 and two unratified 10s. What does the reader build?
Q2. The catalog says latest = 9, but LIST shows 10.json. What must a spec-following reader do?
Q3. The catalog returns version 8 as a staged commit, and 8.json is also published. Which does the spec say to read?
Publishing
Publishing copies ratified commit v to _delta_log/<v>.json. Because a ratified commit’s content is immutable, it “does not matter whether the client-side, server-side, or both catalog components initiate publishing.” Commits must be published in order, v - 1 before v, so the published prefix of the log never has a hole. Prompt publishing is encouraged, because it shrinks what the catalog must store and serve.[PROTOCOL]
Publishing happens some time after the commit, so a published file’s modification time is not the commit time. That breaks chapter 9’s timestamp-based time travel, so catalog-managed tables must use in-commit timestamps: commitInfo.inCommitTimestamp is written at commit time and read instead of the mtime. Spark encodes the dependency in the feature itself. CatalogManagedTableFeature.requiredFeatures is inCommitTimestamp and vacuumProtocolCheck.[src]
Try it
Commit as writer A with each of the three options, then make writer B race for a version A already won. Publish, and watch the catalog’s map empty while latest stays. Finally let a filesystem-only writer drop a <v>.json behind the catalog’s back and see the reader ignore it. The panels are driven by src/sim/delta/catalog.ts, whose tests include the spec’s reading example.
_delta_log/
0.json1.json
Reader's plan
Snapshot version 1.
- v0: published
- v1: published
- Table created; versions 0 and 1 are published.
The commit as a sequence
- resolve name → location, catalogManaged. Table discovery happens before the protocol is known, so the name lookup itself should say the table is catalog-managed. Table Discovery ↗
- getRatifiedCommits → latest 8, [7, 8]. Commits 7 and 8 are ratified but unpublished, so LIST alone would miss them. The writer combines them with the published files to build version 8. PROTOCOL.md ↗
- PUT _staged_commits/9.<uuid>.json. Option 1: stage the commit. The content is the same as a published commit.
commitInfomust carryinCommitTimestamp(required for catalog-managed tables) and a uniquetxnId. A staged file alone means nothing: it may be a failed or in-progress attempt. Commit Protocol ↗ - PUT _staged_commits/9.<uuid2>.json. Writer B also read version 8 and stages its own version 9. The UUID in the name means the two files never collide.
- commit(9, location) ✓ ratified. The catalog records atomically that version 9 is A's staged file. It must not ratify 9 before 8, and must ratify 9 at most once. InMemoryCommitCoordinator ↗
- commit(9, location2) ✗. Version 9 is taken. B gets a version conflict and, ideally, the latest ratified commits with it, so it can rebase and try 10 without another round trip. Its staged file is left behind and ignored. Commit Protocol ↗
- publish: copy 7, 8, 9 → <v>.json. Publishing copies ratified commits into the log in order: 7 before 8 before 9. Because the content is immutable, anyone may publish. The Spark connector calls this backfill: with batch size 1 it backfills right after each commit, otherwise every
batchSizeversions. AbstractBatchBackfillingCommitCoordinatorClient ↗ - registerBackfill(9). The catalog can forget commits up to 9. It still keeps
latest = 9, which stays authoritative. registerBackfill ↗ - getRatifiedCommits → latest 9, []. Readers always ask the catalog first. If it returns commits, those win over published files with the same version, and files above
latestare ignored. Reader Requirements ↗ - LIST → …, 9.json. Everything up to 9 is now published, so the listing completes the snapshot.
Maintenance
Checkpoints and log compaction files read published deltas, so they “can only be created for versions that are already published”. To checkpoint v, or compact x..y with x <= v <= y, <v>.json must exist. Version checksum files are the exception: a <v>.crc may be written for an unpublished v.[PROTOCOL]
Everything else is prohibited by default unless the managing catalog permits it: metadata cleanup, VACUUM, and data layout changes such as OPTIMIZE and REORG. Checkpoints, compaction and checksums are allowed because “they are essential for all basic table operations”. The catalog owns the table’s lifecycle, so it decides when files may be deleted or rewritten.
Creating and dropping tables is also left to the catalog. Creation often takes three steps: get a unique storage location for a staging table, initialize a catalogManaged table there, and register it under its name. Dropping can be a soft delete of the name, followed later by a purge.[PROTOCOL]
Q1. Without explicit permission from the catalog, which may a client run on a catalog-managed table? (select all that apply)
Q2. Version 12 is ratified but not published. Which file may be written for it?
Q3. Why must catalog-managed tables use in-commit timestamps?
Writer and reader requirements
When the feature is supported and active, writers must:[PROTOCOL]
- discover and access the table through catalog calls;
- have
inCommitTimestampsupported and active; - put a unique
txnIdstring in everycommitInfo; - commit only through the catalog’s commit protocol, never with an ordinary filesystem commit;
- follow the maintenance rules above.
Readers must discover the table through the catalog, ask it for unpublished ratified commits, ignore versions above the catalog’s latest, and prefer the catalog’s commit over a published file for the same version.[PROTOCOL]
Table discovery has a chicken-and-egg problem. The client learns that a table is catalog-managed from its protocol, but it must contact the catalog before reading the protocol. The spec’s answer is to use the step engines already perform: when the catalog resolves a table name to a storage location, the same response should say whether the table is catalog-managed. That adds no round trip.[PROTOCOL]
Q1. A client must use catalog calls before it can read the table's protocol. How does it learn the table is catalog-managed?
Q2. Which are writer requirements on a catalog-managed table? (select all that apply)
The Spark connector
The connector’s code predates the spec’s terms. It calls the catalog a commit coordinator, staged commits unbackfilled commits, and publishing backfill. There is also an older writer-only feature, coordinatedCommits-preview, next to catalogManaged.[src] Three behaviors matter.
Version 0 goes through the filesystem. AbstractBatchBackfillingCommitCoordinatorClient.commit throws CommitFailedException(false, false, "Commit version 0 must go via filesystem."). The table is created with an ordinary 0.json, and the coordinator takes over from version 1.[src]
Stage, ratify, then backfill by batch. The commit writes the actions with writeUnbackfilledCommitFile (a staged file with a fresh UUID), then calls the coordinator’s commitImpl to ratify it. After that it backfills. With batchSize <= 1 it backfills before writing (up to v - 1) and right after ratifying (version v). Otherwise it backfills everything up to v when v % batchSize == 0, or when the table is converting back to a filesystem table.[src] backfillToVersion asks the coordinator for the unbackfilled commits up to the target and backfills each in order. backfill writes <v>.json with overwrite off and then calls registerBackfill(v), after which the coordinator drops its entries up to v. If the file already exists, someone else published it, and the write is skipped.[src][src]
Listed files win in the merge. SnapshotManagement lists the log, fetches unbackfilled commits, and lists again if the two leave a gap. It then keeps every listed delta and drops the coordinator’s commits at or below the highest listed version:[src]
val unbackfilledCommitsFiltered = unbackfilledCommitsResponse.getCommits.asScala
.dropWhile(_.getVersion <= maxDeltaVersionSeen)
.takeWhile(commit => versionToLoad.forall(commit.getVersion <= _))
.map(_.getFileStatus)
This is the reverse of the spec’s rule 3, and it is safe only because published and ratified copies are byte-identical. It also doesn’t apply rule 4 by itself. latestTableVersion is used to decide whether another LIST is needed, not to cut off files above it.[src] The simulator’s readPlan(…, 'spark') mode implements this merge, and a test shows 7 coming from 7.json instead of the catalog.
Q1. In the Spark connector's AbstractBatchBackfillingCommitCoordinatorClient, how is version 0 committed?
Q2. With batchSize = 10, after ratifying version 23, what does the connector backfill?
Q3. The Spark connector lists 7.json and the coordinator still returns 7 and 8. Which 7 does it use?
Summary
- With
catalogManaged(reader 3, writer 7), the catalog decides which proposal is versionv. Filesystem-only clients are fenced out. - Commits are proposed, then staged or inline, then ratified, then published. Only
<v>.jsonproves a version on its own. A staged file proves nothing. - The three commit options are staged + ratify, inline, and PUT-if-absent. Ratification is in order and at most once, and a conflict should return the latest ratified commits.
- Readers ask the catalog first, LIST only for what’s missing, prefer the catalog’s copy, and ignore files above the catalog’s latest version.
- Publishing copies ratified commits in order. It needs in-commit timestamps, and only published versions can be checkpointed or compacted. Other maintenance needs the catalog’s permission.
- The Spark connector stages, ratifies and backfills by batch, starts coordination at version 1, and in its listing merge lets published files win over the coordinator’s copies.
Concepts in this chapter
Explained here
Primary sources
Review this chapter
This chapter has 20 quiz questions.