Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
v4.2.1
Commit ID
Other Environment Information
- Environment: MatrixOne Cloud (MOC) serverless tenant
- Server: 8.0.30-MatrixOne-v4.2.1
- Client: PyMySQL over TLS
- Source: @TrentShen (feedback dated 2026-10-21)
Actual Behavior
After a view has been granted to a role, CREATE OR REPLACE VIEW replaces its catalog object with a new logical object ID. Existing grants remain associated with the previous ID (on v4.2.1) and no longer authorize queries. A reader then gets error 20101. Granting SELECT on the replacement view again restores access.
This was observed in production and reproduced on the reported v4.2.1 image. MatrixOne main also loses the effective grant during replacement, although its DROP cleanup removes the old privilege row instead of leaving it orphaned.
Expected Behavior
Replacing the definition of an existing view with the same name should preserve that view's existing grants. If replacement is intended to have DROP-and-CREATE privilege semantics, the behavior should be explicitly documented and surfaced rather than silently invalidating access during an idempotent DDL replay.
Steps to Reproduce
Run as a tenant administrator:
CREATE DATABASE app;
CREATE TABLE app.t1 (id INT);
INSERT INTO app.t1 VALUES (42);
CREATE VIEW app.v1 AS SELECT id FROM app.t1;
CREATE ROLE reader;
GRANT CONNECT ON ACCOUNT * TO reader;
CREATE USER observer IDENTIFIED BY 'test-password' DEFAULT ROLE reader;
GRANT reader TO observer;
GRANT SELECT ON VIEW app.v1 TO reader;Connect as observer with role reader and verify:
SELECT * FROM app.v1;
-- Returns 42.As administrator, replace the view with the same definition:
CREATE OR REPLACE VIEW app.v1 AS SELECT id FROM app.t1;In a fresh observer session, run SELECT * FROM app.v1 again. It fails with error 20101. As administrator, regrant and retry:
GRANT SELECT ON VIEW app.v1 TO reader;The reader query succeeds after the new grant. Comparing the view's catalog logical ID before and after replacement shows that it changed, while the original grant referred to the old object ID.
Additional information
The behavior makes routine idempotent view deployment silently revoke access. Replacement should preserve the existing logical identity and grants, or migrate the grants to the replacement object as part of the same operation. A regression test should also check that an actual DROP followed by CREATE does not inherit the dropped view's grants.
Activity
fix: preserve view authorization across index joins and replacement (#…
XuPeng-SH commentedon Oct 22, 2026
QA follow-up for PR #30820, updated head
551de35250d6f52eff054db874c7567f70ba0c1c:The new commit moves effective logical-ID resolution before the transaction relation's
GetTableDefcache is materialized. It adds an engine regression and extends the tenant SQL case for repeated replacement with commit/rollback and grant retention. Static review indicates this directly addresses the stale cachedLogicalId=0path from the earlier P2.The author reports the engine/compile/plan suites, focused race test, build, vet/lint and related BVTs passing on this head; these are author-reported results, not an independent rerun. A re-review was requested, but the formal
CHANGES_REQUESTEDreview still targets the prior head, and its inline thread remains unresolved. The current head has no combined status checks; MongoDB and Iceberg connector workflows are in progress and unrelated.I consider the reported root cause addressed by the new code and regression, pending exact-head independent verification/formal re-review. Issue remains open; existing assignees (
aptend,Ariznawlll) are unchanged.[4.2-dev] fix: preserve view authorization across index joins and rep…
slyunnn commentedon Oct 23, 2026
Regression and extended verification for #30786 (2026-10-23)
Verification Environment
origin/main:e19f698de0fc52a60f60f2ff689d6d16a5100334—fix(frontend): keep Decimal256 primary-key pairing in DATA BRANCH (#30837). Clean sourceHEADmatched this commit; the runtime was rebuilt with Go1.27.1, Linux/arm64,TYPECHECK=1, and restarted. Binary version, SQLgit_version()and current-start service readiness were verified.551de35250d6f52eff054db874c7567f70ba0c1c—[4.2-dev] fix: initialize logical identity before caching table definitions, the updated head requested in the preceding QA comment. Its matching Go1.26.4, Linux/arm64 binary was restarted and checked. This is the specified backport head, not a claim about the latest4.2-devtip or production deployment.2 CN / 1 TN / 1 Log service / Proxytopology with separate version-owned storage. Actual Proxy127.0.0.1:6001, CN1127.0.0.1:16001and CN2127.0.0.1:16002were reachable, and each endpoint executed the original and extended SQL, not just health checks.COM_QUERY), plus existing mo-tester BVTs through Connector/J. Administrative and fresh reader sessions explicitly set and verifyenable_privilege_cacheas bothOFFandON. Production MOC/TLS and binary prepared-statement execution were not tested.What Was Covered
SELECT ON VIEWreads42, then continues reading42after identical-definitionCREATE OR REPLACE VIEW, without regranting. Direct base-table access remains denied with20101.WITH GRANT OPTIONis checked both in metadata and by successfully delegating access to another role/user.COMMIT; both readers observe the final definition. Two further replacements followed byROLLBACKrestore the committed physical ID, logical ID, definition and grants. This independently exercises the cached logical-ID path highlighted in the preceding comment.1146; replacing a base table returns1050. Failed replacements preserve the existing view, source data, identity, grants and reader access.NULLresults remain accessible. ActualDROP VIEWfollowed byCREATE VIEWgets a new identity and inherits neither the original reader's nor the delegated role's object grants; both are denied with20101. Explicit regrant restores access, and revoke denies it again.282/282checks on main and282/282on the exact backport head. Endpoint jobs ran concurrently with isolated tenants; lifecycle operations within each tenant ran in order. No engine-parallel execution claim is made.IF NOT EXISTS, base-table rejection and lock/delete failures. On the exact backport head, the compiler regression and engineTestCreateTablePublishesLogicalIdentitypassed, including the hidden-index identity control.396/396each run; backport178/178each run. All runs had0failed, abnormal or ignored checks. Created accounts, roles, users, tables/views and snapshots were checked for cleanup; global settings were restored. Main topology was restored afterward.v4.2.1image, concurrent competing DDL, long-lived reader-session invalidation, TKE, performance/soak testing and a new race/full-package run. Author-reported broader validation is not represented as independently rerun here.Findings
Main fix: PR #30799, merge
6495ce997486c2445994081c1d85c39802f7049b—fix: preserve view authorization across index joins and replacement.Backport: PR #30820, merge
4b11cd642008a0fd86ee3087d788f9c057b8a11a—[4.2-dev] fix: preserve view authorization across index joins and replacement. Its tested head includes551de35250, which initializes effective logical identity beforeGetTableDefcaches it.Replacement now retains the view's logical identity rather than applying ordinary drop-and-create grant semantics. Repeated replacement, commit/rollback and independent reader checks passed on both tested versions. This supplies independent functional evidence for the prior QA follow-up; it is not a formal PR review submission or confirmation that production has been upgraded.
MOTR / BVT Coverage
Reused committed regressions:
TestCreateOrReplaceViewPreservesIdentity, mainTestAlterViewPreservesLogicalID, backportTestCreateTablePublishesLogicalIdentity, andgrant_view_non_sys.sql. Main additionally randrop_object_privileges.sql; both versions ran their existingalter_view.sqlandreplace_view.testcases. The backport tenant case directly covers repeated transactional replacement with commit/rollback.No duplicate MOTR case was needed, so no new recording, regression commit, branch push or weekly PR update was made. Existing expected results were compared unchanged. BVTs ran serially/exclusively because they use fixed object names and global cache/case-sensitivity settings; the separate tenant-isolated endpoint matrix ran concurrently. No MatrixOne service or test source was modified.
Final Conclusion
Fixed on the tested latest-main commit and specified
4.2-devbackport head:CREATE OR REPLACE VIEWpreserves existing effective grants, including repeated replacements within a transaction; trueDROP/CREATEremains privilege-isolated.Large-data regression is not required: the defect concerns catalog identity, transaction-local metadata caching and grant binding, not row counts, batch/block boundaries or resource scale. One source row distinguishes the outcomes; additional volume would not improve this acceptance evidence.
The issue remains open for maintainer acceptance. No issue state, labels or assignees were changed.