Skip to content

fix(frontend): persist default role selection - #30709

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Lundomn:codex/issue-30677-default-role
Oct 23, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
Lundomn:codex/issue-30677-default-role

Conversation

@Lundomn

@Lundomn Lundomn commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #30677

What this PR does / why we need it:

Implement the missing SET DEFAULT ROLE execution path and persist the selected role in mo_user.default_role.

  • A user may select only a role directly granted to themselves. Changing another user's default role retains the existing ALTER USER authority.
  • NONE stores public. ALL and multi-role lists are explicitly rejected because MatrixOne stores one default role per user.
  • Validate the role, user/host identity, direct grants and every requested target before writes in one short-lived transaction. Existing sessions retain their active role; login-time validation and fallback remain unchanged.
  • Extend the existing frontend tests and Issue SQL fixture to cover parser/dispatch, authorization, transaction failure/rollback, and multi-target atomicity. The code change is limited to the seven frontend/SQL files in this PR; it does not modify production lockservice behavior.

Validation

Current delivery head: c155d0ef64bf98aa9f7baaa626793a3e1c3ea50a (tree c18a0023de16876bbbd37da13db231da3222d753). The local integration is based on selected upstream snapshot d4c37f4d8722dd91b80f5f5547940004bf1b293f; its PR diff is seven frontend/SQL files (+1,138/-1). The PR base branch has since advanced to 2b388dd1690f83e2e807d6809180336dae2a68eb; at readback, GitHub marked this PR mergeable but behind. The one later upstream commit's overlapping-file hunks are separate from this PR's SET DEFAULT ROLE handler.

  • On the integrated source, selected coverage roots and drain semantics passed; isolated race measurements and four anchored race-count-100 runs passed 100/100; normal lockservice and frontend packages passed; focused frontend normal/race passed; selected frontend+lockservice static check passed with pinned golangci-lint v2.14.0 and 0 issues. gofmt and git diff --check are clean. See the task's E50 source-validation receipt for exact command/log fingerprints.
  • make build passed on this exact source. The built service recorded CN query-ready:true, SQL listener startup, and explicit ISCP-Task Start before the test runs.
  • The existing zz_accesscontrol/issue_30677_set_default_role.sql passed two normal comparison runs on this exact source: 60/60 each, failed/ignored/abnormal 0. Independent post-run catalog checks found no fixture users, roles or database, and the owned service shut down cleanly. Full command, binary/config/log/report hashes, and cleanup evidence are in E51.
  • Hosted CI was just dispatched for actual head c155d0ef64bf98aa9f7baaa626793a3e1c3ea50a; applicable checks are pending. Prior b75 CI results do not establish this head's status. No CI/Required closure is claimed.

Scope and limitations

ALL and multi-role default selections remain unsupported by the single-role catalog representation. The separate authorization-epoch cleanup timeout remains unresolved and is not changed by this PR. This PR is related to #30677; it does not request automatic issue closure, which remains subject to QA sign-off.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: fce997d52f9f30d8cd390270a5ae1e63f21d0096

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: fce997d52f9f30d8cd390270a5ae1e63f21d0096

Review belongs to an older commit; it is not a review of the current head.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: fce997d52f9f30d8cd390270a5ae1e63f21d0096

Assessment: approve

Reviewed the complete seven-file delta and affected authorization, catalog, transaction and login owners. The design appropriately persists default-role selection through existing catalog and transaction mechanisms, validates all targets before writes, and preserves active-session roles and login fallback. No actionable defects remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Traced self-service and cross-user authorization, direct grants, administrator protection, host/principal validation, atomic multi-target updates, rollback/cancellation cleanup, and interactions with role revocation and user/role deletion.

  • Reviewed unit-test assertions and SQL regression expectations covering persistence, fresh login, unchanged active sessions, NONE, rejected role selections and atomic failure.

  • Reused frozen exact-head success records for shared build, Ubuntu unit tests, static analysis, coverage, proxy BVT and pessimistic multi-CN BVT; inspected repository workflow and test selection.

  • Local git diff --check passed. Receipt checks/1792558367397821338-3.json matches the command, frozen HEAD, clean source fingerprint and retained diff-check.log.

  • Review evidence is retained at /home/xupeng/.local/state/mo-bot/jobs/95482d468752221bdf4c7d69/attempt-1/review-evidence.json. Source remained unchanged.

  • New catalog I/O and locks are confined to SET DEFAULT ROLE. Unrelated SQL paths add only a statement-type check; no performance improvement or benchmark result is claimed.

Limitations:

  • No local Go/native tests or live concurrency experiments were executed. Raw CI logs and author execution receipts were unavailable; author validation claims were treated as supplemental evidence.

  • The linked issue #30677 body was absent from frozen evidence; behavioral scope was assessed against the supplied PR contract and existing source behavior.

@mergify mergify Bot added the queued label Oct 21, 2026
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-21 04:56 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-10-21 11:09 UTC · at 8237335b52755f27f75dae309e53e1e84887bc3f

This pull request spent 6 hours 13 minutes 42 seconds in the queue, with no time running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Requeued — the merge queue status continues in this comment ↓.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review completed at exact head fce997d52f9f30d8cd390270a5ae1e63f21d0096 (base/merge-base a648b13e53cf0a07ff19211203a69e37b2d1dd93).

No blocking findings. Read all seven changed files and the complete review/discussion/inline/thread history, plus issue #30677. This is a focused repair of an already parsed no-op, not a new role model; the design-document gate is not triggered.

Change/closure map:

  • R3 authorization/catalog: self-service remains limited to the authenticated principal ID and a direct grant; cross-user changes retain ALTER USER/account authority, administrator protection, tenant-scoped background execution, escaped literals and explicit host validation. Unsupported ALL/multiple-role selections fail explicitly.
  • R3 transaction/lifecycle: role -> deterministically ordered user locks -> ordered grant locks -> validate all targets -> ordered writes -> commit. Traced the interacting REVOKE/DROP USER/DROP ROLE owners, RC semantics, cancellation and failed-write/commit paths. Existing sessions are not switched; fresh login validates the stored grant and retains revoked/deleted-default fallback.
  • UT/BVT: reviewed named positive, denial, host/identity, zero-ID, atomic-failure and commit-failure oracles. Minimum fixtures, scoped global executor restoration and SQL teardown are retained.

Q1-Q3 audit:

Boundary Closure
Q1 private executor/transaction immediate executor Close; transaction finish after successful BEGIN; Close has independent cleanup-context rollback
Q2 creation/query/row locks request-owned cancellable creation; existing statement/transaction lock cancellation and deadlock handling; finish precedes executor destruction
Q3 target/result state bounded by this statement's target list; cleared result sets and lexical maps; no new worker, queue or retained cache

Verified/reused raw exact-head evidence from CI run 39539932444:

  • UT job 119025338762/checkpoint: unfiltered frontend selection with -race -short -tags matrixone_test, stage exit 0.
  • Normal coverage job 119025384078: -count=1 -covermode=set; producer exit 0, 83,507 pass events, no package/test failure events.
  • SCA job 119025338763: repository molint/vet pipeline and pinned golangci-lint 2.14.0, final 0 issues.
  • Proxy BVT job 119028106116: issue_30677_set_default_role.sql 60/60 and revoked_default_role_login.sql 39/39, zero failed/ignored/abnormal.
  • Local isolated exact-head worktree: complete diff and git diff --check passed.

No redundant local Go/native suite or live concurrency experiment was run. Author-reported same-instance repetitions and setter/REVOKE experiments are supplemental, not independently reproduced evidence. No wire/schema change, background generation or new unbounded hot-path mechanism is introduced.

@mergify

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-23 05:30 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-10-23 09:42 UTC · at c05a21bb65ebdfbfce4d0263394f6eff2c4c320f

This pull request spent 4 hours 12 minutes 43 seconds in the queue, with no time running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants