Repository navigation
fix: correct information schema views metadata - #28903
Closed
gouhongshen wants to merge 76 commits into
Closed
gouhongshen wants to merge 76 commits into
gouhongshen wants to merge 76 commits into
Conversation
1 of 7 tasks
Contributor
Author
3 of 7 tasks
XuPeng-SH
added a commit
that referenced
this pull request
Sep 16, 2026
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## 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 lost all recognizable identity when its source had no ordinary tables, or after all cloned ordinary tables were dropped. `DATA BRANCH DELETE DATABASE` could not distinguish that database from an ordinary database and rejected the delete. ### Implementation - Persists the categorical `data-branch` identity in the existing `mo_database.dat_type` field as part of the same internal `CREATE DATABASE` operation. - Uses one cluster-wide `MORPCVersion75` gate for every producer and consumer: create, delete, publication classification, logical snapshot restore, PITR, and account/cluster restore. - Rejects branch-database creation below v75 before DDL; at v75 it writes the marker atomically. - Keeps table-receipt validation for every ordinary table. The database marker handles only the previously ambiguous empty, view-only, sequence-only, and all-tables-dropped cases. - Makes ALTER PUBLICATION classify the effective persisted database even when the statement omits a DATABASE clause, including correct cross-account owner resolution. - Preserves statement-local clone context across reusable `ExecCtx` instances. - Serializes branch database deletion against concurrent object DDL using the existing exclusive `mo_database` catalog-row lock. - Restores the marker from authoritative `dat_type` data and preflights snapshot and PITR source identities at their public restore entries before target-account creation, account deletion, session kill, view-metadata invalidation, foreign-key cleanup, table restore, or database replacement. - Adds focused unit, embedded lifecycle, concurrency, restore, multi-statement, and BVT coverage. ### Compatibility Current main owns protocol versions v64 through v74, with v74 assigned to corrected numeric HEX overload identities. This rebased PR claims the next continuous version, v75; it does not depend on #27716 or #28903. Concurrent PR #28950 must merge afterward as v76; the allocation order is recorded in both PRs. Below v75, new branch-database creation and marked restore input fail before mutation, while existing table-backed branches continue to use table receipts. Downgrade does not erase markers. Re-enabling v75 restores marker-aware behavior without migration. No catalog schema migration is required because `dat_type` already exists and is persisted by backup/checkpoint/replay. The exact design revision is `data-branch-database-identity-2026-09-16-r20`. Revision r20 keeps the v75-then-v76 allocation order and v74/v75 boundary coverage, and moves cluster, account, database, and table snapshot/PITR admission ahead of irreversible account, metadata, FK, and object side effects. ### Validation - `go test ./pkg/frontend -run 'Test(DataBranchDatabaseIdentityCapability|DataBranchCreateDatabaseRejectsBeforeExecutorBelowCapability|PrepareLogicalRestoreDatabaseCapability|NewLogicalRestoreDatabaseDefinitionRequiresTypeColumn|PreflightLogicalRestoreDatabases|ValidateDataBranchDeleteDatabaseTargetUsesDatabaseIdentity|LoadBranchDatabaseTypeRejectsMissingDatabase|InstallDataBranchCloneContextRestoresRequestContext|IsUserDatabaseType|DoAlterPublicationDataBranchIdentityCapability|MarkedDatabaseRestoreRejectsBeforeDestructiveWorkBelowCapability|MarkedAccountRestorePreflightsBeforeDestructiveWorkBelowCapability|ClusterRestorePreflightsBeforeAccountSideEffects|MarkedTableSnapshotRestorePreflightsBeforeFkSideEffects|RestorePitrPreflightsBeforeAccountCreation|RestorePitrPreflightsBeforeExistingAccountSideEffects|MarkedDatabaseRestorePreservesIdentityAtCapability)$' -count=1` - `go test ./pkg/tests/issues -run TestIssue26068DataBranchDatabaseIdentityLifecycle -count=1` - `go test ./pkg/sql/compile -run TestCreateDatabaseChecksExistingBeforeSerializingAbsence -count=1` - `git diff --check origin/main...HEAD` All commands above pass after syncing current main; `go test ./pkg/frontend -count=1` also passes on PR head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7`. Isolated `TestScope_Database` fails with the same `missing lock service` panic on both this branch and exact base `2ea4ec2e6ef4b20321a235ef416228506813e39b`; the PR does not modify that DropDatabase lineage-lock path. CI run 34948994437 passed the shared build, arm64 SCA, UT coverage, and both Compose BVT jobs. Ubuntu/x86 UT ended after 71m43s with the global timeout (Error 124) while unrelated fileservice and vm/engine tests were still active; no #28272-owned test reported a failure. The preceding rebased head 55339dc completed Ubuntu/x86 UT and all required checks successfully. On pre-rebase head `2d2af51450241340058720fe786d55a64d1db784`, all build, SCA, and BVT checks passed. The two unrelated failures were rerun after their logs established infrastructure or shared-runner causes: Ubuntu/x86 UT passed in about 49 minutes, and UT Coverage passed in about 30 minutes. On preceding head `81d463a7922448f5713ce10f9463a396e6876ba7`, build, arm64 SCA, UT Coverage, both BVT jobs, and the authorized Ubuntu/x86 UT rerun all passed. Rebased review-fix head `822050e783141dc047260991d1b8c6d67e57c474` passed build, arm64 SCA, UT Coverage, Ubuntu/x86 UT, and both Compose BVT jobs. Current restore-entry review-fix head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7` is running CI. The diff is confined to data-branch database identity, its producer/consumer/restore paths, design, and tests; no CI workflow is changed. --------- Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#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 lost all recognizable identity when its source had no ordinary tables, or after all cloned ordinary tables were dropped. `DATA BRANCH DELETE DATABASE` could not distinguish that database from an ordinary database and rejected the delete. ### Implementation - Persists the categorical `data-branch` identity in the existing `mo_database.dat_type` field as part of the same internal `CREATE DATABASE` operation. - Uses one cluster-wide `MORPCVersion75` gate for every producer and consumer: create, delete, publication classification, logical snapshot restore, PITR, and account/cluster restore. - Rejects branch-database creation below v75 before DDL; at v75 it writes the marker atomically. - Keeps table-receipt validation for every ordinary table. The database marker handles only the previously ambiguous empty, view-only, sequence-only, and all-tables-dropped cases. - Makes ALTER PUBLICATION classify the effective persisted database even when the statement omits a DATABASE clause, including correct cross-account owner resolution. - Preserves statement-local clone context across reusable `ExecCtx` instances. - Serializes branch database deletion against concurrent object DDL using the existing exclusive `mo_database` catalog-row lock. - Restores the marker from authoritative `dat_type` data and preflights snapshot and PITR source identities at their public restore entries before target-account creation, account deletion, session kill, view-metadata invalidation, foreign-key cleanup, table restore, or database replacement. - Adds focused unit, embedded lifecycle, concurrency, restore, multi-statement, and BVT coverage. ### Compatibility Current main owns protocol versions v64 through v74, with v74 assigned to corrected numeric HEX overload identities. This rebased PR claims the next continuous version, v75; it does not depend on matrixorigin#27716 or matrixorigin#28903. Concurrent PR matrixorigin#28950 must merge afterward as v76; the allocation order is recorded in both PRs. Below v75, new branch-database creation and marked restore input fail before mutation, while existing table-backed branches continue to use table receipts. Downgrade does not erase markers. Re-enabling v75 restores marker-aware behavior without migration. No catalog schema migration is required because `dat_type` already exists and is persisted by backup/checkpoint/replay. The exact design revision is `data-branch-database-identity-2026-09-16-r20`. Revision r20 keeps the v75-then-v76 allocation order and v74/v75 boundary coverage, and moves cluster, account, database, and table snapshot/PITR admission ahead of irreversible account, metadata, FK, and object side effects. ### Validation - `go test ./pkg/frontend -run 'Test(DataBranchDatabaseIdentityCapability|DataBranchCreateDatabaseRejectsBeforeExecutorBelowCapability|PrepareLogicalRestoreDatabaseCapability|NewLogicalRestoreDatabaseDefinitionRequiresTypeColumn|PreflightLogicalRestoreDatabases|ValidateDataBranchDeleteDatabaseTargetUsesDatabaseIdentity|LoadBranchDatabaseTypeRejectsMissingDatabase|InstallDataBranchCloneContextRestoresRequestContext|IsUserDatabaseType|DoAlterPublicationDataBranchIdentityCapability|MarkedDatabaseRestoreRejectsBeforeDestructiveWorkBelowCapability|MarkedAccountRestorePreflightsBeforeDestructiveWorkBelowCapability|ClusterRestorePreflightsBeforeAccountSideEffects|MarkedTableSnapshotRestorePreflightsBeforeFkSideEffects|RestorePitrPreflightsBeforeAccountCreation|RestorePitrPreflightsBeforeExistingAccountSideEffects|MarkedDatabaseRestorePreservesIdentityAtCapability)$' -count=1` - `go test ./pkg/tests/issues -run TestIssue26068DataBranchDatabaseIdentityLifecycle -count=1` - `go test ./pkg/sql/compile -run TestCreateDatabaseChecksExistingBeforeSerializingAbsence -count=1` - `git diff --check origin/main...HEAD` All commands above pass after syncing current main; `go test ./pkg/frontend -count=1` also passes on PR head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7`. Isolated `TestScope_Database` fails with the same `missing lock service` panic on both this branch and exact base `2ea4ec2e6ef4b20321a235ef416228506813e39b`; the PR does not modify that DropDatabase lineage-lock path. CI run 34948994437 passed the shared build, arm64 SCA, UT coverage, and both Compose BVT jobs. Ubuntu/x86 UT ended after 71m43s with the global timeout (Error 124) while unrelated fileservice and vm/engine tests were still active; no matrixorigin#28272-owned test reported a failure. The preceding rebased head 55339dc completed Ubuntu/x86 UT and all required checks successfully. On pre-rebase head `2d2af51450241340058720fe786d55a64d1db784`, all build, SCA, and BVT checks passed. The two unrelated failures were rerun after their logs established infrastructure or shared-runner causes: Ubuntu/x86 UT passed in about 49 minutes, and UT Coverage passed in about 30 minutes. On preceding head `81d463a7922448f5713ce10f9463a396e6876ba7`, build, arm64 SCA, UT Coverage, both BVT jobs, and the authorized Ubuntu/x86 UT rerun all passed. Rebased review-fix head `822050e783141dc047260991d1b8c6d67e57c474` passed build, arm64 SCA, UT Coverage, Ubuntu/x86 UT, and both Compose BVT jobs. Current restore-entry review-fix head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7` is running CI. The diff is confined to data-branch database identity, its producer/consumer/restore paths, design, and tests; no CI workflow is changed. --------- Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#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 lost all recognizable identity when its source had no ordinary tables, or after all cloned ordinary tables were dropped. `DATA BRANCH DELETE DATABASE` could not distinguish that database from an ordinary database and rejected the delete. ### Implementation - Persists the categorical `data-branch` identity in the existing `mo_database.dat_type` field as part of the same internal `CREATE DATABASE` operation. - Uses one cluster-wide `MORPCVersion75` gate for every producer and consumer: create, delete, publication classification, logical snapshot restore, PITR, and account/cluster restore. - Rejects branch-database creation below v75 before DDL; at v75 it writes the marker atomically. - Keeps table-receipt validation for every ordinary table. The database marker handles only the previously ambiguous empty, view-only, sequence-only, and all-tables-dropped cases. - Makes ALTER PUBLICATION classify the effective persisted database even when the statement omits a DATABASE clause, including correct cross-account owner resolution. - Preserves statement-local clone context across reusable `ExecCtx` instances. - Serializes branch database deletion against concurrent object DDL using the existing exclusive `mo_database` catalog-row lock. - Restores the marker from authoritative `dat_type` data and preflights snapshot and PITR source identities at their public restore entries before target-account creation, account deletion, session kill, view-metadata invalidation, foreign-key cleanup, table restore, or database replacement. - Adds focused unit, embedded lifecycle, concurrency, restore, multi-statement, and BVT coverage. ### Compatibility Current main owns protocol versions v64 through v74, with v74 assigned to corrected numeric HEX overload identities. This rebased PR claims the next continuous version, v75; it does not depend on matrixorigin#27716 or matrixorigin#28903. Concurrent PR matrixorigin#28950 must merge afterward as v76; the allocation order is recorded in both PRs. Below v75, new branch-database creation and marked restore input fail before mutation, while existing table-backed branches continue to use table receipts. Downgrade does not erase markers. Re-enabling v75 restores marker-aware behavior without migration. No catalog schema migration is required because `dat_type` already exists and is persisted by backup/checkpoint/replay. The exact design revision is `data-branch-database-identity-2026-09-16-r20`. Revision r20 keeps the v75-then-v76 allocation order and v74/v75 boundary coverage, and moves cluster, account, database, and table snapshot/PITR admission ahead of irreversible account, metadata, FK, and object side effects. ### Validation - `go test ./pkg/frontend -run 'Test(DataBranchDatabaseIdentityCapability|DataBranchCreateDatabaseRejectsBeforeExecutorBelowCapability|PrepareLogicalRestoreDatabaseCapability|NewLogicalRestoreDatabaseDefinitionRequiresTypeColumn|PreflightLogicalRestoreDatabases|ValidateDataBranchDeleteDatabaseTargetUsesDatabaseIdentity|LoadBranchDatabaseTypeRejectsMissingDatabase|InstallDataBranchCloneContextRestoresRequestContext|IsUserDatabaseType|DoAlterPublicationDataBranchIdentityCapability|MarkedDatabaseRestoreRejectsBeforeDestructiveWorkBelowCapability|MarkedAccountRestorePreflightsBeforeDestructiveWorkBelowCapability|ClusterRestorePreflightsBeforeAccountSideEffects|MarkedTableSnapshotRestorePreflightsBeforeFkSideEffects|RestorePitrPreflightsBeforeAccountCreation|RestorePitrPreflightsBeforeExistingAccountSideEffects|MarkedDatabaseRestorePreservesIdentityAtCapability)$' -count=1` - `go test ./pkg/tests/issues -run TestIssue26068DataBranchDatabaseIdentityLifecycle -count=1` - `go test ./pkg/sql/compile -run TestCreateDatabaseChecksExistingBeforeSerializingAbsence -count=1` - `git diff --check origin/main...HEAD` All commands above pass after syncing current main; `go test ./pkg/frontend -count=1` also passes on PR head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7`. Isolated `TestScope_Database` fails with the same `missing lock service` panic on both this branch and exact base `2ea4ec2e6ef4b20321a235ef416228506813e39b`; the PR does not modify that DropDatabase lineage-lock path. CI run 34948994437 passed the shared build, arm64 SCA, UT coverage, and both Compose BVT jobs. Ubuntu/x86 UT ended after 71m43s with the global timeout (Error 124) while unrelated fileservice and vm/engine tests were still active; no matrixorigin#28272-owned test reported a failure. The preceding rebased head 55339dc completed Ubuntu/x86 UT and all required checks successfully. On pre-rebase head `2d2af51450241340058720fe786d55a64d1db784`, all build, SCA, and BVT checks passed. The two unrelated failures were rerun after their logs established infrastructure or shared-runner causes: Ubuntu/x86 UT passed in about 49 minutes, and UT Coverage passed in about 30 minutes. On preceding head `81d463a7922448f5713ce10f9463a396e6876ba7`, build, arm64 SCA, UT Coverage, both BVT jobs, and the authorized Ubuntu/x86 UT rerun all passed. Rebased review-fix head `822050e783141dc047260991d1b8c6d67e57c474` passed build, arm64 SCA, UT Coverage, Ubuntu/x86 UT, and both Compose BVT jobs. Current restore-entry review-fix head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7` is running CI. The diff is confined to data-branch database identity, its producer/consumer/restore paths, design, and tests; no CI workflow is changed. --------- Co-authored-by: XuPeng-SH <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes
Fixes #27655
Supersedes #27716, whose author branch is read-only for this account and is behind current main. The replacement preserves the reviewed implementation while making the current-main protocol allocation explicit.
What this PR does / why we need it
Information-schema VIEWS previously exposed incomplete or non-replayable metadata for persisted views. This PR makes the contract structural and mixed-version safe.
Validation
All passed locally.