fix(frontend): persist data branch database identity - #28272
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 25fe6784bcfe31929ec646a9ca860a12d46d54fc across catalog ownership, delete safety, legacy fallback, cross-account creation, publication consumers, rollback, BVT isolation, and mixed-version operation. The local implementation is internally coherent: the marker is written atomically with CREATE DATABASE; ordinary empty/subscription/unknown targets remain rejected; every present ordinary table still needs an active receipt; and focused UT/BVT cover the intended success and safety cases. One mandatory persistent-contract/rollout blocker remains.
[P1] Design and gate the new persistent database type for mixed-version clusters
This PR introduces a new durable mo_database.dat_type value and changes DATA BRANCH DELETE semantics, but the repository’s approved docs/design/data_branch_privilege.md still fixes the opposite contract: empty/view-only/sequence-only databases must fail closed, and database-level branch identity requires a separate design/implementation step. The PR neither updates that versioned design nor records an approved replacement decision, migration/rollback contract, or capability gate.
This is already a concrete mixed-version failure, not documentation drift. A new CN writes dat_type = data-branch; an old CN treats every non-empty dat_type as a non-user database in create/alter publication validation, so the same branch database accepts or rejects publication operations depending on which CN receives the request. Conversely, an old CN can create an empty/view-only branch without the marker, and a new CN must permanently reject its DATA BRANCH DELETE because there is no trustworthy identity to recover. During rollout, persistent state and user-visible behavior are therefore CN-version-dependent.
Please update the design document and obtain the required design decision for the marker/identity model, including upgrade, downgrade/rollback, mixed-version creation/deletion/publication behavior, and backup/restore. Implement a rollout/capability rule that prevents new persistent semantics from being emitted until all eligible CNs can consume them (or provide another reviewed compatibility mechanism). Add deterministic mixed-version/capability tests for old-created and new-created empty and table-backed branches. Merely documenting the current inconsistency as a residual risk is not sufficient for a new catalog contract.
No separate hot-path, unbounded-state, wait, cleanup, privilege, or SQL-injection blocker was found in the reviewed implementation.
|
Unrelated CI blocker: workflow run |
54e5d3d to
5a15ac6
Compare
The blocker remains valid and in scope. The latest The implementation commit remains patch-identical. The rebase was conflict-free, and the focused compile/frontend tests passed against the new planner/compiler/protobuf baseline. Production gating and restore changes remain blocked pending approval of section 12; the PR remains Draft. |
The blocker remains valid and in scope. Latest The implementation commit remains patch-identical. The rebase was conflict-free, and the focused compile/frontend tests passed against the bytejson/protocol baseline. Production gating and restore changes remain blocked pending independent approval of section 12; the PR remains Draft. |
|
Ready-for-review gate evaluated at exact head The final diff and PR description are internally consistent, the branch is conflict-free against I am keeping the PR Draft because the mandatory design gate is still open: revision |
|
Ready-for-review gate evaluated at exact head The final diff and PR description are consistent, the branch is conflict-free against I am keeping the PR Draft because the mandatory persistent-contract design gate remains open. Revision |
|
Rebased onto latest Post-rebase compile and frontend focused tests passed. The PR description now records the exact base/head and validation. The PR remains Draft because design revision |
|
Rebased onto latest Post-rebase compile and frontend focused tests passed. The complete PR description now records the exact base/head and validation. The PR remains Draft because design revision |
|
The latest The rebase was conflict-free. Range-diff shows the implementation commit remains patch-identical; the design commit changes only the necessary rollout version and records the v53 owner. Post-rebase compile and frontend focused tests passed, and the complete PR description is updated. Production gating and restore work remain blocked pending independent design approval; the PR remains Draft. |
|
Ready-for-review gate evaluated at exact head The final diff and complete PR description are consistent, the branch is conflict-free and current on I am keeping the PR Draft because the mandatory persistent-contract design gate remains open. Revision |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Post-rebase compile DDL and frontend data-branch/publication focused tests passed. The complete PR description now records the exact base/head and validation. The PR remains Draft because design revision |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Post-rebase focused compile DDL, frontend data-branch/publication, protocol discovery, and CN startup-order tests passed. The complete PR description now records the exact base/head and validation. The PR remains Draft because design revision |
|
The latest The new base also adds subscription index metadata routing and dependency-ordered standalone shutdown. The subscription change overlaps Post-rebase compile DDL and focused frontend data-branch/publication tests passed, including the upstream explicit-table deduplication control. The complete PR description now records the exact base/head and validation. The PR remains Draft because r7 still lacks independent approval; production gating, logical snapshot/PITR marker preservation, and deterministic v54/v55 tests remain blocked on that decision. |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Post-rebase focused compile DDL and frontend data-branch/publication tests passed. The complete PR description now records the exact base/head and validation. The PR remains Draft because design revision |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Because the planner function change is in the frontend dependency closure, post-rebase focused compile DDL and frontend data-branch/publication tests were rerun and passed. The complete PR description now records the exact base/head and validation. The PR remains Draft because design revision |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Semantic inspection confirms the upstream DDL changes compose with the typed internal CREATE DATABASE path. Post-rebase focused compile DDL and frontend data-branch/publication tests passed, and The PR remains Draft because design revision |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Post-rebase focused JSON_UNQUOTE planner tests, the frontend prepared-statement control, compile DDL, and frontend data-branch/publication tests passed; The PR remains Draft because design revision |
|
Rebased onto latest The lifecycle change overlaps compile, publication, snapshot, and PITR paths. Semantic inspection confirms it composes with this PR, does not consume Focused catalog lifecycle-lock, compile DDL/revalidation, and frontend data-branch/publication/lifecycle-context tests passed; The PR remains Draft because design revision |
|
A final freshness check found one additional upstream commit, so I rebased again onto The rebase was conflict-free and range-diff again shows both PR commits patch-identical. Focused compile DDL/revalidation and frontend data-branch/publication/lifecycle-context tests passed on the new head; The PR remains Draft with the same mandatory blocker: design revision |
|
The latest The upstream change overlaps Focused session-temporary-DDL compile/frontend tests and this PR's compile DDL, data-branch, publication, and lifecycle-context tests passed on an isolated Go build cache; The PR remains Draft because r8 still lacks independent approval; production gating, logical snapshot/PITR marker preservation, and deterministic v55/v56 tests remain blocked on that decision. |
|
Rebased onto latest The rebase was conflict-free, and range-diff shows both PR commits remain patch-identical. Post-rebase focused compile DDL and frontend data-branch/publication tests passed; The PR remains Draft because design revision |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #26068
What this PR does / why we need it:
Root cause
Database-branch identity was inferred only from active ordinary-table rows in
mo_branch_metadata. A successfully created branch database therefore had no durable database-level identity when its source had no ordinary tables, or after all cloned ordinary tables were dropped.DATA BRANCH DELETE DATABASEcould not distinguish it from an ordinary database and rejected the delete.Design-review status
This PR is Draft and its persistent-contract implementation remains blocked pending independent approval of design revision
data-branch-database-identity-2026-09-07-r8indocs/design/data_branch_privilege.mdsection 12.The proposed contract uses
mo_database.dat_type = 'data-branch'behind cluster-wideMORPCVersion56. Below v56, new CNs reject database-branch creation before DDL and all consumers retain legacy behavior. Revision r8 uses v56 because currentmainassigns v48 to the generation-aware CDC watermark catalog contract, v49 to vector-level grouping-set projection expansion, v50/v51 to the ordered ODKU protocol contracts, v52 to MySQL binary JSON subtype tags, v53 to ordered-stream distributed Top-N merge, v54 to catalog-authenticated proxy prepared-cache reuse, and v55 to session-owned temporary DDL with transactional data. The proposal also defines upgrade, mixed-version, downgrade/rollback, physical backup, logical snapshot/PITR restore, alternatives, and deterministic compatibility tests.The existing production implementation at this head predates that capability and restore work and must not be approved or merged until the design is approved and the code/tests are brought into exact alignment.
Current implementation
data-branchdatabase type and attach it to the internalCREATE DATABASE, somo_database.dat_typeis written atomically with the database definition. This avoids a second catalog update in the clone transaction.Issue-to-test proof already present
dat_type = 'data-branch', deletes the branch, and asserts the destination is absent.data-branch.After design approval, deterministic v55/v56 creation, deletion, publication, snapshot, and PITR cases listed in section 12.7 are mandatory before this PR returns to Ready for review.
Tests run
make build.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/catalog.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/sql/compile.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/frontendbranch_database_identity.sql: 62/62 passed twice on the same local service instancebranch_metadata.sqlcontrol selection: 59/59 passedbranch/privilege/branch_privilege.sql: 258/258 passedeb637e0ec10d8e3a6f2dad128161ab32d14c661f: all 28 checks reached successful, skipped, or neutral terminal statesorigin/main39225f5fbc63b44a190cdd43f954ee07d78e6cdc; range-diff shows both PR commits remain patch-identicalMORPCVersion55and overlapspkg/sql/compile/ddl.go; semantic inspection confirms its CREATE TABLE routing is independent of this PR's typed CREATE DATABASE path. The lifecycle change still does not preservemo_database.dat_typeduring logical restore. The latest MongoDB delta is isolated to its query translator, tests, RFC, and E2E harness and does not overlap this PR or consumeMORPCVersion56TestCreateDatabaseChecksExistingBeforeSerializingAbsence, all four focused session-temporary-DDL compile tests,TestRequireViewMetadataRevalidationRejectsMissingRefreshGate, andTestViewMetadataRevalidationActivationPropagatesCatalogErrorspassedTestHandleGetProtocolVersionIncludesPendingCNspassed, proving pending CNs remain in common-protocol discoveryTestCNStartsQueryServiceBeforeViewMetadataAdmissionandTestCNStartPropagatesQueryServiceStartFailurepassedTestLockViewMetadataLifecycleOrderAndErrorspassed for the shared catalog lock helper9fd92cd87b675eb539afec0a7b3a12720f625cc3:git diff --checkpassedKnown blockers and residual risks
data-branchwithout a common-protocol gate, and logical snapshot/PITR restore does not preserve the marker. These are the active P1 blockers addressed by the proposed design, not accepted residual risk.mo_database.dat_typecolumn.