Repository navigation
docs: promote changes across tables with one multi-table commit - #5740
kotwal-itpro wants to merge 4 commits into
Conversation
5e11eec to
1ab13dc
Compare
|
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
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
1ab13dc to
d90d397
Compare
|
Thanks for the review. All addressed in d90d397, rebased on current main:
|
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.
d90d397 to
8a670c2
Compare
|
@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 |
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
mainof every table to its branch head in one commit that assertsmainhasn'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.mdwalks 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_PROPERTIESandTABLE_CREATEon every table) and that federated and static-facade catalogs aren't supported.Test:
BranchPromotionRecipeTestruns the recipe through the REST handler with three tables:promotesEveryTableAtOnce: branch created in one commit, one snapshot written to each branch, promotion movesmainof all three tables to their branch heads.promotesNothingWhenOneTableMovedOnMain: after branching, another writer movesmainof 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-idis 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
CHANGELOG.md(if needed) — not needed, docs and test onlysite/content/in-dev/unreleased(if needed)