fix: clean role privileges when dropping objects - #27745
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? |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed the complete merge-base-to-head diff at 424db1e against the current origin/main, including the GRANT/DROP catalog-lock protocol, transaction generation/admission, prepared-statement database binding, clone/restore ownership, hidden-index cleanup, DDL identity preservation, and the focused UT/BVT/integration coverage.
No P0, P1, P2, or P3 findings remain. The database-before-relation lock order, pessimistic-RC refresh/retry behavior, cleanup ownership, rollback paths, and logical-ID preservation are internally consistent, and the exact-head CI is complete.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27723
What this PR does / why we need it:
GRANTand persistent object replacement/deletion through database-before-relation catalog locks.ALTER VIEW; includeALTER VIEWin lifecycle admission.mo_tablescatalog row for source-relation DROP while skipping only the unavailable source storage lock.EXECUTEbefore transaction admission and use the prepared statement's binding database when classifying unqualified temporary-table aliases.CREATE OR REPLACE VIEW,ALTER VIEW, andDROP SEQUENCEin the persistent lifecycle protocol.DROP TABLEtargets against session temporary aliases before admission, so temp-only drops remain valid in existing optimistic transactions while mixed/persistent drops use the catalog protocol.Validation:
TestIssue26087ConcurrentDataBranchQuotapassed.DROP TABLE tbound in d1 was rejected despite an execute-time d2 temporary alias; d1.t remained.mo_role_privsrows.clone_subscription.sql: 106/106 passed after separating clone owner mode from snapshot-operator selection.pkg/frontendandpkg/sql/compilepackage runs passed;go vet ./pkg/frontend ./pkg/sql/compilepassed.golangci-lint 2.6.2 -c .golangci.yml ./pkg/frontend ./pkg/sql/compile— 0 issues.Additional review closures
TxnHandler.Createwhen storage initialization or validity checking fails; admission rejection still preserves a pre-existing transaction.ALTER SEQUENCE, skip replacement-only DROP cleanup, and admit ALTER through the pessimistic-RC lifecycle protocol.__mo_index_relations before catalog lookup/mutation, preventing internal index tables from becoming user authorization objects.Additional validation:
Binary admission and legacy-index follow-up
PrepareStmt.defaultDatabasein the binary COM_STMT_EXECUTE input beforedoComQuery, so transaction admission sees the correct PREPARE-time binding even though binary execution supplies the inner AST.Validation:
Review round 9
CREATE OR REPLACE VIEWandALTER SEQUENCE.SHOW PROCESSLISTwitnesses the competing statement, and final catalog assertions cover both GRANT-first and DROP-first orderings.Validation:
TestIssue23861FulltextSnapshotRestore -count=10: PASS (67.65s).TestIssue27723GrantDropLifecycleLockProtocol -count=3: PASS.-race -count=1: PASS.go vetandgolangci-lintfor frontend, compile, and issues: PASS / 0 issues.Review round 10
SHOW PROCESSLISTapproximation in the two-session GRANT↔DROP test with a lockservice enqueue observation at the exact point where the request is linked to conflicting holders and marked blocking. Both holder orders now wait for that barrier before release/commit.t.Cleanup; connection cleanup also uses LIFO test cleanup, so release occurs before connection close onFailNowor timeout.docs/design/CLAUDE_ISSUE_27723_OBJECT_PRIVILEGE_LIFECYCLE.md. It defines lock order/concurrency, logical identity, transaction generation/admission, prepared binding, private restore/clone ownership, compatibility/rollback, alternatives, security, and the deterministic validation matrix.Round 10 validation:
-count=3: PASS.-race -count=1: PASS.pkg/lockservice: PASS; full owning package under-race: PASS.pkg/frontendandpkg/sql/compile: PASS after merging latestmo/main.go vetandgolangci-lintover frontend/compile/lockservice/issues: PASS / 0 issues.Design review approval
Independent technical review of design revision
7670e86db96db9f8b2b6d8d13845957d8d175c12concluded PASS on 2026-08-29.