Repository navigation
fix: validate implicit default role grants - #27717
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? |
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 0d300397c358efcaad112d215730782a1557deb1.
The fix closes #27651 at the correct trust boundary: an implicit login no longer activates mo_user.default_role metadata directly; it requires a matching mo_role row and mo_user_grant membership in the same lookup. A stale/NULL/invalid default can fall back only to role ID 1 when both the user's public grant and the canonical public role name are present; missing rows, malformed values, and query failures fail closed. Explicit-role validation remains unchanged, existing-session semantics are intentionally unchanged, and retaining the stored default allows a later regrant to recover it.
Performance is acceptable: the normal implicit-login path still performs one role lookup, now an indexed join on mo_role.role_id and mo_user_grant(role_id,user_id); only the revoked/stale path performs the second public lookup. There is no per-statement cost or unbounded state.
Unhappy paths are covered at helper and protocol/BVT levels: revoked/missing/NULL/malformed/out-of-range defaults, invalid public fallback, catalog failures, non-default revocation control, protected privilege denial, existing sessions, and regrant recovery. git diff --check passes and exact-head Ubuntu UT, SCA, coverage, Proxy BVT, and pessimistic BVT are green. No blocker found.
Merge Queue Status
This pull request spent 24 minutes 54 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #27717 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
) ## What changed This PR makes normal-user authentication establish one fresh catalog snapshot before reading account, user, password, lock, role, grant, system-variable, or login-database state. - Capture the serving CN's HLC uncertainty upper bound and install the smallest timestamp that dominates every HLC value at that bound. - Wait for the local logtail through the effective monotonic session minimum **before** constructing the authentication executor or entering user transaction admission. `TxnClient.New` then rechecks the same minimum. - Preserve a larger caller minimum in both transaction freshness modes. - Keep `max-clock-offset` as the ordering bound even when active local clock monitoring is disabled, in process and embedded launchers. - Make the handshake request context the single timeout owner of authentication freshness waiting and transaction creation. Ordinary transactions retain `CreateTxnOpTimeout`. - Reject authentication-enabled CN configurations that cannot cover the pairwise clock geometry: `connectTimeout > 2 * max-clock-offset + 1ns`, with checked arithmetic. `skipCheckUser=true` bypasses only this unreachable authentication-specific budget check; general clock validation still runs. - Revalidate public embedded `Adjust`/pre-start mutations before creating resources. The operator's immutable service type owns validation, and a callback cannot relabel a CN as a TN to bypass the authentication budget. - Let the built-in timestamp waiter observe transaction-client closure directly, avoiding a derived context and `context.AfterFunc` allocation per login while retaining the compatibility fallback for legacy waiter implementations. The complete design and validation map are in [`docs/design/authentication_catalog_freshness.md`](docs/design/authentication_catalog_freshness.md). ## Root cause With sacrificing freshness enabled, a new session has no prior commit timestamp, so authentication could start from the latest logtail already applied by its local CN. A security mutation could already have committed and returned on another CN while this CN still read the previous catalog generation. The observed failure was `REVOKE` followed by an immediate `GRANT` of the stored default role. A new connection routed to a lagging CN validated the old revoked generation, fell back to `public`, and denied a table read that the regranted role permits. The same stale-snapshot shape applies to account state, user/password and lock state, explicit role grants, and login database resolution, so the repair belongs at the authentication snapshot boundary. ## Correctness and unhappy paths - The login linearization point is the HLC uncertainty-bound capture under the existing cluster clock contract. - The pre-admission wait must report a watermark at or beyond the effective session minimum; missing runtime/clock/transaction client, negative offset, timestamp overflow, wait failure, cancellation, client close, and regressing watermark all fail closed. - A failed pre-admission wait creates no transaction operator. The timestamp waiter owns and removes its entry on success, cancellation, notification, or close. Later transaction-creation failure retains the existing abort owner. - Bootstrap-only special users and `skipCheckUser` retain their existing catalog-free paths. - Embedded post-parse mutations are revalidated before resource creation; invalid budgets and service-identity mismatches leave no cleanup obligation. - One waiter exists per in-flight normal login, bounded by the handshake deadline and connection count. No new goroutine, RPC, persisted state, collection, or rolling-upgrade dependency is introduced. This repairs new-login catalog freshness. Existing authenticated-session role revocation remains the separate lifecycle handled by PR #27737. ## Performance - The default ordinary-SQL transaction hot path is unchanged. - The unavoidable uncertainty/logtail wait occurs before transaction admission, so it no longer consumes a `max-active` user-transaction slot. Connection pooling amortizes this connection-establishment cost for TP workloads. - A normal login adds one local HLC read and reuses the existing timestamp waiter; it adds no cross-CN RPC or goroutine. - The built-in waiter close fast path removes one derived context and `context.AfterFunc` allocation from each authentication wait. - The non-default freshness-preserving branch adds one timestamp comparison and no allocation, lock, or I/O. - Embedded revalidation is startup-only and occurs before resource allocation; it has no query-path cost. ## Validation Candidate head: `9a646c2a33` on main `745d8364c5` (Go 1.26.4, `-mod=readonly`, repository CGo/native libraries). - Focused config/authentication/waiter tests passed, including `skipCheckUser`, monotonic existing minimum, missing dependencies, downstream failure, watermark regression, executor ordering, cancellation, client close, post-parse invalid budget, and mutable-service-type bypass. - Full normal suites passed for `pkg/config`, `cmd/mo-service`, `pkg/embed`, `pkg/frontend`, `pkg/txn/client`, and `pkg/txn/clock`. - Full race suites passed for `pkg/embed`, `pkg/frontend`, and `pkg/txn/client`. - The cancellation/close/snapshot barrier tests passed 100 repetitions under the race detector; they use no sleeps, polling, retries, or weakened assertions. - `go vet` passed for every changed Go package; formatting, module-file, and diff checks passed. - Exact-head `make build` passed with `CommitID=9a646c2a33`. - The existing public revoke/regrant semantics were exercised through Proxy on one LogService, one TN, and two CNs. New sessions immediately observed revoke fallback and regrant on alternating CN connections; a deliberately retained old session kept its old role, matching the separate #27737 scope. Incident evidence: https://github.com/matrixorigin/matrixone/actions/runs/33067372509/job/98502820591?pr=27758 Related: #27717, #27737, #27758
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: close matrixorigin#27651 ## What this PR does / why we need it: Implicit login trusted `mo_user.default_role` without confirming that the role was still granted to the user. After revoking the default role, a new implicit session could therefore activate that role and retain its privileges, while explicit-role login correctly rejected it. This change: - validates an implicit default role against both `mo_role` and `mo_user_grant` before activation; - falls back to a valid `public` grant when the stored default is stale, NULL, invalid, or missing, and fails closed when no valid fallback exists; - preserves explicit-role validation, existing-session behavior, and default-role recovery after regrant; - adds focused unit coverage for valid, revoked, regranted, NULL, missing, malformed, out-of-range, and query-error paths; - adds BVT coverage for explicit and implicit role behavior, new and existing sessions, protected privileges, secondary-role revoke control, and regrant recovery. Local verification: - `go test ./pkg/frontend/... -count=1` - `go test -race ./pkg/frontend/... -count=1` - `go vet ./pkg/frontend/...` - changed functions coverage: 100%; frontend package coverage: 63.7% - revoked_default_role_login BVT: 39/39 passed - local 1 Log / 1 TN / 1 CN protocol E2E with privilege cache enabled and disabled - `make config` - `make err-check` - `make build-with-prebuilt-native` - `git diff --check` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…rixorigin#27763) ## What changed This PR makes normal-user authentication establish one fresh catalog snapshot before reading account, user, password, lock, role, grant, system-variable, or login-database state. - Capture the serving CN's HLC uncertainty upper bound and install the smallest timestamp that dominates every HLC value at that bound. - Wait for the local logtail through the effective monotonic session minimum **before** constructing the authentication executor or entering user transaction admission. `TxnClient.New` then rechecks the same minimum. - Preserve a larger caller minimum in both transaction freshness modes. - Keep `max-clock-offset` as the ordering bound even when active local clock monitoring is disabled, in process and embedded launchers. - Make the handshake request context the single timeout owner of authentication freshness waiting and transaction creation. Ordinary transactions retain `CreateTxnOpTimeout`. - Reject authentication-enabled CN configurations that cannot cover the pairwise clock geometry: `connectTimeout > 2 * max-clock-offset + 1ns`, with checked arithmetic. `skipCheckUser=true` bypasses only this unreachable authentication-specific budget check; general clock validation still runs. - Revalidate public embedded `Adjust`/pre-start mutations before creating resources. The operator's immutable service type owns validation, and a callback cannot relabel a CN as a TN to bypass the authentication budget. - Let the built-in timestamp waiter observe transaction-client closure directly, avoiding a derived context and `context.AfterFunc` allocation per login while retaining the compatibility fallback for legacy waiter implementations. The complete design and validation map are in [`docs/design/authentication_catalog_freshness.md`](docs/design/authentication_catalog_freshness.md). ## Root cause With sacrificing freshness enabled, a new session has no prior commit timestamp, so authentication could start from the latest logtail already applied by its local CN. A security mutation could already have committed and returned on another CN while this CN still read the previous catalog generation. The observed failure was `REVOKE` followed by an immediate `GRANT` of the stored default role. A new connection routed to a lagging CN validated the old revoked generation, fell back to `public`, and denied a table read that the regranted role permits. The same stale-snapshot shape applies to account state, user/password and lock state, explicit role grants, and login database resolution, so the repair belongs at the authentication snapshot boundary. ## Correctness and unhappy paths - The login linearization point is the HLC uncertainty-bound capture under the existing cluster clock contract. - The pre-admission wait must report a watermark at or beyond the effective session minimum; missing runtime/clock/transaction client, negative offset, timestamp overflow, wait failure, cancellation, client close, and regressing watermark all fail closed. - A failed pre-admission wait creates no transaction operator. The timestamp waiter owns and removes its entry on success, cancellation, notification, or close. Later transaction-creation failure retains the existing abort owner. - Bootstrap-only special users and `skipCheckUser` retain their existing catalog-free paths. - Embedded post-parse mutations are revalidated before resource creation; invalid budgets and service-identity mismatches leave no cleanup obligation. - One waiter exists per in-flight normal login, bounded by the handshake deadline and connection count. No new goroutine, RPC, persisted state, collection, or rolling-upgrade dependency is introduced. This repairs new-login catalog freshness. Existing authenticated-session role revocation remains the separate lifecycle handled by PR matrixorigin#27737. ## Performance - The default ordinary-SQL transaction hot path is unchanged. - The unavoidable uncertainty/logtail wait occurs before transaction admission, so it no longer consumes a `max-active` user-transaction slot. Connection pooling amortizes this connection-establishment cost for TP workloads. - A normal login adds one local HLC read and reuses the existing timestamp waiter; it adds no cross-CN RPC or goroutine. - The built-in waiter close fast path removes one derived context and `context.AfterFunc` allocation from each authentication wait. - The non-default freshness-preserving branch adds one timestamp comparison and no allocation, lock, or I/O. - Embedded revalidation is startup-only and occurs before resource allocation; it has no query-path cost. ## Validation Candidate head: `9a646c2a33` on main `745d8364c5` (Go 1.26.4, `-mod=readonly`, repository CGo/native libraries). - Focused config/authentication/waiter tests passed, including `skipCheckUser`, monotonic existing minimum, missing dependencies, downstream failure, watermark regression, executor ordering, cancellation, client close, post-parse invalid budget, and mutable-service-type bypass. - Full normal suites passed for `pkg/config`, `cmd/mo-service`, `pkg/embed`, `pkg/frontend`, `pkg/txn/client`, and `pkg/txn/clock`. - Full race suites passed for `pkg/embed`, `pkg/frontend`, and `pkg/txn/client`. - The cancellation/close/snapshot barrier tests passed 100 repetitions under the race detector; they use no sleeps, polling, retries, or weakened assertions. - `go vet` passed for every changed Go package; formatting, module-file, and diff checks passed. - Exact-head `make build` passed with `CommitID=9a646c2a33`. - The existing public revoke/regrant semantics were exercised through Proxy on one LogService, one TN, and two CNs. New sessions immediately observed revoke fallback and regrant on alternating CN connections; a deliberately retained old session kept its old role, matching the separate matrixorigin#27737 scope. Incident evidence: https://github.com/matrixorigin/matrixone/actions/runs/33067372509/job/98502820591?pr=27758 Related: matrixorigin#27717, matrixorigin#27737, matrixorigin#27758
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: close matrixorigin#27651 ## What this PR does / why we need it: Implicit login trusted `mo_user.default_role` without confirming that the role was still granted to the user. After revoking the default role, a new implicit session could therefore activate that role and retain its privileges, while explicit-role login correctly rejected it. This change: - validates an implicit default role against both `mo_role` and `mo_user_grant` before activation; - falls back to a valid `public` grant when the stored default is stale, NULL, invalid, or missing, and fails closed when no valid fallback exists; - preserves explicit-role validation, existing-session behavior, and default-role recovery after regrant; - adds focused unit coverage for valid, revoked, regranted, NULL, missing, malformed, out-of-range, and query-error paths; - adds BVT coverage for explicit and implicit role behavior, new and existing sessions, protected privileges, secondary-role revoke control, and regrant recovery. Local verification: - `go test ./pkg/frontend/... -count=1` - `go test -race ./pkg/frontend/... -count=1` - `go vet ./pkg/frontend/...` - changed functions coverage: 100%; frontend package coverage: 63.7% - revoked_default_role_login BVT: 39/39 passed - local 1 Log / 1 TN / 1 CN protocol E2E with privilege cache enabled and disabled - `make config` - `make err-check` - `make build-with-prebuilt-native` - `git diff --check` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…rixorigin#27763) ## What changed This PR makes normal-user authentication establish one fresh catalog snapshot before reading account, user, password, lock, role, grant, system-variable, or login-database state. - Capture the serving CN's HLC uncertainty upper bound and install the smallest timestamp that dominates every HLC value at that bound. - Wait for the local logtail through the effective monotonic session minimum **before** constructing the authentication executor or entering user transaction admission. `TxnClient.New` then rechecks the same minimum. - Preserve a larger caller minimum in both transaction freshness modes. - Keep `max-clock-offset` as the ordering bound even when active local clock monitoring is disabled, in process and embedded launchers. - Make the handshake request context the single timeout owner of authentication freshness waiting and transaction creation. Ordinary transactions retain `CreateTxnOpTimeout`. - Reject authentication-enabled CN configurations that cannot cover the pairwise clock geometry: `connectTimeout > 2 * max-clock-offset + 1ns`, with checked arithmetic. `skipCheckUser=true` bypasses only this unreachable authentication-specific budget check; general clock validation still runs. - Revalidate public embedded `Adjust`/pre-start mutations before creating resources. The operator's immutable service type owns validation, and a callback cannot relabel a CN as a TN to bypass the authentication budget. - Let the built-in timestamp waiter observe transaction-client closure directly, avoiding a derived context and `context.AfterFunc` allocation per login while retaining the compatibility fallback for legacy waiter implementations. The complete design and validation map are in [`docs/design/authentication_catalog_freshness.md`](docs/design/authentication_catalog_freshness.md). ## Root cause With sacrificing freshness enabled, a new session has no prior commit timestamp, so authentication could start from the latest logtail already applied by its local CN. A security mutation could already have committed and returned on another CN while this CN still read the previous catalog generation. The observed failure was `REVOKE` followed by an immediate `GRANT` of the stored default role. A new connection routed to a lagging CN validated the old revoked generation, fell back to `public`, and denied a table read that the regranted role permits. The same stale-snapshot shape applies to account state, user/password and lock state, explicit role grants, and login database resolution, so the repair belongs at the authentication snapshot boundary. ## Correctness and unhappy paths - The login linearization point is the HLC uncertainty-bound capture under the existing cluster clock contract. - The pre-admission wait must report a watermark at or beyond the effective session minimum; missing runtime/clock/transaction client, negative offset, timestamp overflow, wait failure, cancellation, client close, and regressing watermark all fail closed. - A failed pre-admission wait creates no transaction operator. The timestamp waiter owns and removes its entry on success, cancellation, notification, or close. Later transaction-creation failure retains the existing abort owner. - Bootstrap-only special users and `skipCheckUser` retain their existing catalog-free paths. - Embedded post-parse mutations are revalidated before resource creation; invalid budgets and service-identity mismatches leave no cleanup obligation. - One waiter exists per in-flight normal login, bounded by the handshake deadline and connection count. No new goroutine, RPC, persisted state, collection, or rolling-upgrade dependency is introduced. This repairs new-login catalog freshness. Existing authenticated-session role revocation remains the separate lifecycle handled by PR matrixorigin#27737. ## Performance - The default ordinary-SQL transaction hot path is unchanged. - The unavoidable uncertainty/logtail wait occurs before transaction admission, so it no longer consumes a `max-active` user-transaction slot. Connection pooling amortizes this connection-establishment cost for TP workloads. - A normal login adds one local HLC read and reuses the existing timestamp waiter; it adds no cross-CN RPC or goroutine. - The built-in waiter close fast path removes one derived context and `context.AfterFunc` allocation from each authentication wait. - The non-default freshness-preserving branch adds one timestamp comparison and no allocation, lock, or I/O. - Embedded revalidation is startup-only and occurs before resource allocation; it has no query-path cost. ## Validation Candidate head: `9a646c2a33` on main `745d8364c5` (Go 1.26.4, `-mod=readonly`, repository CGo/native libraries). - Focused config/authentication/waiter tests passed, including `skipCheckUser`, monotonic existing minimum, missing dependencies, downstream failure, watermark regression, executor ordering, cancellation, client close, post-parse invalid budget, and mutable-service-type bypass. - Full normal suites passed for `pkg/config`, `cmd/mo-service`, `pkg/embed`, `pkg/frontend`, `pkg/txn/client`, and `pkg/txn/clock`. - Full race suites passed for `pkg/embed`, `pkg/frontend`, and `pkg/txn/client`. - The cancellation/close/snapshot barrier tests passed 100 repetitions under the race detector; they use no sleeps, polling, retries, or weakened assertions. - `go vet` passed for every changed Go package; formatting, module-file, and diff checks passed. - Exact-head `make build` passed with `CommitID=9a646c2a33`. - The existing public revoke/regrant semantics were exercised through Proxy on one LogService, one TN, and two CNs. New sessions immediately observed revoke fallback and regrant on alternating CN connections; a deliberately retained old session kept its old role, matching the separate matrixorigin#27737 scope. Incident evidence: https://github.com/matrixorigin/matrixone/actions/runs/33067372509/job/98502820591?pr=27758 Related: matrixorigin#27717, matrixorigin#27737, matrixorigin#27758
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: close matrixorigin#27651 ## What this PR does / why we need it: Implicit login trusted `mo_user.default_role` without confirming that the role was still granted to the user. After revoking the default role, a new implicit session could therefore activate that role and retain its privileges, while explicit-role login correctly rejected it. This change: - validates an implicit default role against both `mo_role` and `mo_user_grant` before activation; - falls back to a valid `public` grant when the stored default is stale, NULL, invalid, or missing, and fails closed when no valid fallback exists; - preserves explicit-role validation, existing-session behavior, and default-role recovery after regrant; - adds focused unit coverage for valid, revoked, regranted, NULL, missing, malformed, out-of-range, and query-error paths; - adds BVT coverage for explicit and implicit role behavior, new and existing sessions, protected privileges, secondary-role revoke control, and regrant recovery. Local verification: - `go test ./pkg/frontend/... -count=1` - `go test -race ./pkg/frontend/... -count=1` - `go vet ./pkg/frontend/...` - changed functions coverage: 100%; frontend package coverage: 63.7% - revoked_default_role_login BVT: 39/39 passed - local 1 Log / 1 TN / 1 CN protocol E2E with privilege cache enabled and disabled - `make config` - `make err-check` - `make build-with-prebuilt-native` - `git diff --check` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…rixorigin#27763) ## What changed This PR makes normal-user authentication establish one fresh catalog snapshot before reading account, user, password, lock, role, grant, system-variable, or login-database state. - Capture the serving CN's HLC uncertainty upper bound and install the smallest timestamp that dominates every HLC value at that bound. - Wait for the local logtail through the effective monotonic session minimum **before** constructing the authentication executor or entering user transaction admission. `TxnClient.New` then rechecks the same minimum. - Preserve a larger caller minimum in both transaction freshness modes. - Keep `max-clock-offset` as the ordering bound even when active local clock monitoring is disabled, in process and embedded launchers. - Make the handshake request context the single timeout owner of authentication freshness waiting and transaction creation. Ordinary transactions retain `CreateTxnOpTimeout`. - Reject authentication-enabled CN configurations that cannot cover the pairwise clock geometry: `connectTimeout > 2 * max-clock-offset + 1ns`, with checked arithmetic. `skipCheckUser=true` bypasses only this unreachable authentication-specific budget check; general clock validation still runs. - Revalidate public embedded `Adjust`/pre-start mutations before creating resources. The operator's immutable service type owns validation, and a callback cannot relabel a CN as a TN to bypass the authentication budget. - Let the built-in timestamp waiter observe transaction-client closure directly, avoiding a derived context and `context.AfterFunc` allocation per login while retaining the compatibility fallback for legacy waiter implementations. The complete design and validation map are in [`docs/design/authentication_catalog_freshness.md`](docs/design/authentication_catalog_freshness.md). ## Root cause With sacrificing freshness enabled, a new session has no prior commit timestamp, so authentication could start from the latest logtail already applied by its local CN. A security mutation could already have committed and returned on another CN while this CN still read the previous catalog generation. The observed failure was `REVOKE` followed by an immediate `GRANT` of the stored default role. A new connection routed to a lagging CN validated the old revoked generation, fell back to `public`, and denied a table read that the regranted role permits. The same stale-snapshot shape applies to account state, user/password and lock state, explicit role grants, and login database resolution, so the repair belongs at the authentication snapshot boundary. ## Correctness and unhappy paths - The login linearization point is the HLC uncertainty-bound capture under the existing cluster clock contract. - The pre-admission wait must report a watermark at or beyond the effective session minimum; missing runtime/clock/transaction client, negative offset, timestamp overflow, wait failure, cancellation, client close, and regressing watermark all fail closed. - A failed pre-admission wait creates no transaction operator. The timestamp waiter owns and removes its entry on success, cancellation, notification, or close. Later transaction-creation failure retains the existing abort owner. - Bootstrap-only special users and `skipCheckUser` retain their existing catalog-free paths. - Embedded post-parse mutations are revalidated before resource creation; invalid budgets and service-identity mismatches leave no cleanup obligation. - One waiter exists per in-flight normal login, bounded by the handshake deadline and connection count. No new goroutine, RPC, persisted state, collection, or rolling-upgrade dependency is introduced. This repairs new-login catalog freshness. Existing authenticated-session role revocation remains the separate lifecycle handled by PR matrixorigin#27737. ## Performance - The default ordinary-SQL transaction hot path is unchanged. - The unavoidable uncertainty/logtail wait occurs before transaction admission, so it no longer consumes a `max-active` user-transaction slot. Connection pooling amortizes this connection-establishment cost for TP workloads. - A normal login adds one local HLC read and reuses the existing timestamp waiter; it adds no cross-CN RPC or goroutine. - The built-in waiter close fast path removes one derived context and `context.AfterFunc` allocation from each authentication wait. - The non-default freshness-preserving branch adds one timestamp comparison and no allocation, lock, or I/O. - Embedded revalidation is startup-only and occurs before resource allocation; it has no query-path cost. ## Validation Candidate head: `9a646c2a33` on main `745d8364c5` (Go 1.26.4, `-mod=readonly`, repository CGo/native libraries). - Focused config/authentication/waiter tests passed, including `skipCheckUser`, monotonic existing minimum, missing dependencies, downstream failure, watermark regression, executor ordering, cancellation, client close, post-parse invalid budget, and mutable-service-type bypass. - Full normal suites passed for `pkg/config`, `cmd/mo-service`, `pkg/embed`, `pkg/frontend`, `pkg/txn/client`, and `pkg/txn/clock`. - Full race suites passed for `pkg/embed`, `pkg/frontend`, and `pkg/txn/client`. - The cancellation/close/snapshot barrier tests passed 100 repetitions under the race detector; they use no sleeps, polling, retries, or weakened assertions. - `go vet` passed for every changed Go package; formatting, module-file, and diff checks passed. - Exact-head `make build` passed with `CommitID=9a646c2a33`. - The existing public revoke/regrant semantics were exercised through Proxy on one LogService, one TN, and two CNs. New sessions immediately observed revoke fallback and regrant on alternating CN connections; a deliberately retained old session kept its old role, matching the separate matrixorigin#27737 scope. Incident evidence: https://github.com/matrixorigin/matrixone/actions/runs/33067372509/job/98502820591?pr=27758 Related: matrixorigin#27717, matrixorigin#27737, matrixorigin#27758
What type of PR is this?
Which issue(s) this PR fixes:
close #27651
What this PR does / why we need it:
Implicit login trusted
mo_user.default_rolewithout confirming that the role was still granted to the user. After revoking the default role, a new implicit session could therefore activate that role and retain its privileges, while explicit-role login correctly rejected it.This change:
mo_roleandmo_user_grantbefore activation;publicgrant when the stored default is stale, NULL, invalid, or missing, and fails closed when no valid fallback exists;Local verification:
go test ./pkg/frontend/... -count=1go test -race ./pkg/frontend/... -count=1go vet ./pkg/frontend/...make configmake err-checkmake build-with-prebuilt-nativegit diff --check