Skip to content

docs: promote changes across tables with one multi-table commit - #5740

Open
kotwal-itpro wants to merge 4 commits into
apache:mainfrom
kotwal-itpro:docs-multi-table-promotion
Open

kotwal-itpro wants to merge 4 commits into
apache:mainfrom
kotwal-itpro:docs-multi-table-promotion

Conversation

@kotwal-itpro

@kotwal-itpro kotwal-itpro commented Oct 8, 2026 •

Copy link
Copy Markdown

Related to #3469. Follows Dmitri's suggestion on the dev@ thread "[DISCUSS] Catalog-level branches for atomic multi-table promotion" to start with a test and a doc for option B.

Users who backfill or publish several related tables need readers to see either the old state of all of them or the new state of all of them. Polaris can already do this with Iceberg branches and the multi-table commit endpoint: create the branch on every table in one commit, write to it, then move main of every table to its branch head in one commit that asserts main hasn't moved. This PR documents that recipe and adds a test that pins the behavior it relies on.

Doc: site/content/in-dev/unreleased/multi-table-promotion.md walks through the steps with request bodies, says what the recipe doesn't cover (schema changes are table-wide on Iceberg branches, only existing tables can be branched, the client tracks membership), and notes the privileges a multi-table commit needs (TABLE_WRITE_PROPERTIES and TABLE_CREATE on every table) and that federated and static-facade catalogs aren't supported.

Test: BranchPromotionRecipeTest runs the recipe through the REST handler with three tables:

  • promotesEveryTableAtOnce: branch created in one commit, one snapshot written to each branch, promotion moves main of all three tables to their branch heads.
  • promotesNothingWhenOneTableMovedOnMain: after branching, another writer moves main of one table; the promotion commit is rejected and none of the three tables change.

The conflict test pins the requirement check: the promotion is rejected when assert-ref-snapshot-id is checked, before the single metastore write. It doesn't exercise atomicity under a real concurrent race.

The test uses the in-memory metastore of the service tests. On the multi-entity consistency discussion (thread): the recipe only updates the refs of the tables it commits, and each of those is written with a check against the version that was read, so it doesn't rely on validations that depend on other entities. Happy to add the same test against the NoSQL persistence if that's useful.

No code changes outside the test.

I used an AI coding assistant while preparing this change; I reviewed and tested all of it and am responsible for it.

Checklist

  • 🛡️ Don't disclose security issues! (contact [email protected])
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Related to Catalog-level branching for atomic multi-table operations #3469
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed) — not needed, docs and test only
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@kotwal-itpro

Copy link
Copy Markdown
Author

This has been open since Oct 14 and is mergeable. It documents and tests promoting several tables at once with the existing multi-table commit, covering both the success case and the case where one table moved on main and nothing changes. Qiegang's transactions design (#5833) publishes with the same commit when main hasn't moved, so the test may also be useful there. @dimas-b @jbonofre, would one of you have time to review?

@orca-review-bot orca-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice small step for #3469. The doc is clear, and the privilege and static-facade notes match the handler (RbacOperationSemantics COMMIT_TRANSACTION = TABLE_WRITE_PROPERTIES + TABLE_CREATE). A few asks inline: tighten the conflict assertion, make the test send the step-1 request the doc shows, and tone down the reader-consistency wording.

One note on the conflict test: the promotion is rejected when the assert-ref-snapshot-id requirement is checked, before the single metastore write. So it pins the requirement check, not atomicity under a real concurrent race. That's fine for this PR, but can the description say so?

Can we use a docs: prefix in the PR title, since it becomes the squash subject? No CHANGELOG entry needed.

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

new MetadataUpdate.AddSnapshot(snapshot(moved, concurrent, bases.get(1))),
setRef("main", concurrent)))));

assertThatThrownBy(() -> promote(bases, heads)).isNotNull();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes on any exception. A bad snapshot JSON or a 400 from setup would look like a successful rejection. The failed ref assertion throws CommitFailedException (the 409 the doc promises), so can we assert .isInstanceOf(CommitFailedException.class)?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

commit(changes);
}

private void createBranchOnAll(List<Long> bases) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 1 of the doc creates the branch with an assert-ref-snapshot-id on main, but this sends no requirements. Can we add new UpdateRequirement.AssertRefSnapshotID("main", bases.get(i)) here so the test runs the request the doc shows?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

}
```

Readers now see the new state of every table. If another writer changed `main` of any of the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit is all-or-nothing, but readers still load each table separately. A reader that loads orders before the promotion and items after it sees a mix. Can we soften this line? Can we also add a bullet under "What this does not cover" saying reads that span several tables aren't pinned to one point?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

@kotwal-itpro
kotwal-itpro force-pushed the docs-multi-table-promotion branch from 1ab13dc to d90d397 Compare October 28, 2026 18:05
@kotwal-itpro kotwal-itpro changed the title Docs and test: promote changes across tables with one multi-table commit docs: promote changes across tables with one multi-table commit Oct 28, 2026
@kotwal-itpro

Copy link
Copy Markdown
Author

Thanks for the review. All addressed in d90d397, rebased on current main:

  • The conflict test now asserts CommitFailedException.
  • The branch is created with assert-ref-snapshot-id on main, the request the doc shows.
  • The doc no longer says readers see every table at once. A new item under "What this does not cover" says reads that span several tables aren't pinned to one point.
  • The title now has the docs: prefix, and the description says the conflict test pins the requirement check, not a concurrent race.

Describe how to make a change visible on several tables at once with
Iceberg branches and the multi-table commit endpoint: create the branch
on every table in one commit, write to it, then move main of every
table to its branch head in one commit that asserts main hasn't moved.
Also list what this doesn't cover (schema changes are table-wide, only
existing tables) and the privileges it needs.

Related to apache#3469.
Add a step between writing to the branch and promoting it: compare each
table's main snapshot with the branch head (snapshot summaries, or the
create_changelog_view procedure for row-level changes), then promote
exactly the reviewed snapshots.
Assert that the rejected promotion fails with CommitFailedException, create the branch with the assert-ref-snapshot-id requirement the doc shows, and say that reads spanning several tables aren't pinned to one point.
@kotwal-itpro
kotwal-itpro force-pushed the docs-multi-table-promotion branch from d90d397 to 8a670c2 Compare November 12, 2026 19:41
@kotwal-itpro

Copy link
Copy Markdown
Author

@dimas-b @jbonofre, a gentle follow-up. I rebased this on current main; the test still passes.

It may be more useful now: on dev@, Qiegang plans to use BranchPromotionRecipeTest as the baseline for the fast-forward publish in the multi-table transactions design (https://lists.apache.org/thread/14jck5st47dx96c0q71nkjrvdy643jjs), so having it on main would let both describe the same commit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants