Repository navigation
fix(frontend): enforce fresh authentication snapshots across CNs - #27763
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? |
|
Follow-up pushed in
Changed-package normal tests, full frontend/txn-client race suites, 100x deterministic cancellation/close race tests, changed-package |
|
Completed repeated deep-review/fix cycles on head 9a646c2 after merging current main 745d836. Round 1 found a public embedded-startup validation bypass: ServiceOperator.Adjust runs after file validation, so an invalid authentication clock budget could reach Start. Commit 0cb6968 revalidates before resource creation and adds a deterministic no-cleanup regression test. Round 2 found the same bypass through identity mutation: Adjust could change cfg.ServiceType to TN while the operator still starts a CN from its immutable serviceType. Commit c249f72 rejects the identity mismatch and validates the budget against the immutable runtime type. The subsequent full-suite feedback loop found two compatibility regressions in test/partial-config callers. Commits 3c60f8d and 9a646c2 preserve the Sirius gate fixture identity and restore non-CN/partial-config defaulting without reopening the runtime bypass. Final audit result: no remaining blocking correctness, lifecycle, performance, or unhappy-path finding. Q1 ownership closes on every prewait/create failure; Q2 request cancel, client close, and waiter close all terminate; Q3 retained waiter state is bounded by concurrent handshakes and removed on every terminal path. Default ordinary SQL remains unchanged; startup checks are off-path, and the only non-default txn hot-path addition is one timestamp comparison. Exact-head evidence: full normal suites for pkg/config, cmd/mo-service, pkg/embed, pkg/frontend, pkg/txn/client, pkg/txn/clock; full race suites for pkg/embed, pkg/frontend, pkg/txn/client; focused cancellation/close/snapshot race tests x100; vet for all changed packages; diff/module checks; and make build with CommitID=9a646c2a33 all passed. PR body and design evidence are synchronized. Ready for re-review; remote CI was not awaited. |
|
Repeated deep-review pass completed on exact head
Fresh evidence this pass: normal tests passed for Result: no new blocking correctness, lifecycle, performance, compatibility, or unhappy-path finding. The remaining |
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.
timestamp that dominates every HLC value at that bound.
before constructing the authentication executor or entering user
transaction admission.
TxnClient.Newthen rechecks the same minimum.max-clock-offsetas the ordering bound even when active local clockmonitoring is disabled, in process and embedded launchers.
freshness waiting and transaction creation. Ordinary transactions retain
CreateTxnOpTimeout.pairwise clock geometry:
connectTimeout > 2 * max-clock-offset + 1ns, withchecked arithmetic.
skipCheckUser=truebypasses only this unreachableauthentication-specific budget check; general clock validation still runs.
Adjust/pre-start mutations before creatingresources. The operator's immutable service type owns validation, and a
callback cannot relabel a CN as a TN to bypass the authentication budget.
avoiding a derived context and
context.AfterFuncallocation per login whileretaining the compatibility fallback for legacy waiter implementations.
The complete design and validation map are in
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
REVOKEfollowed by an immediateGRANTof the storeddefault 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 regrantedrole 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
existing cluster clock contract.
session minimum; missing runtime/clock/transaction client, negative offset,
timestamp overflow, wait failure, cancellation, client close, and regressing
watermark all fail closed.
waiter owns and removes its entry on success, cancellation, notification, or
close. Later transaction-creation failure retains the existing abort owner.
skipCheckUserretain their existingcatalog-free paths.
invalid budgets and service-identity mismatches leave no cleanup obligation.
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
so it no longer consumes a
max-activeuser-transaction slot. Connectionpooling amortizes this connection-establishment cost for TP workloads.
waiter; it adds no cross-CN RPC or goroutine.
context.AfterFuncallocation from each authentication wait.no allocation, lock, or I/O.
it has no query-path cost.
Validation
Candidate head:
9a646c2a33on main745d8364c5(Go 1.26.4,-mod=readonly, repository CGo/native libraries).skipCheckUser,monotonic existing minimum, missing dependencies, downstream failure,
watermark regression, executor ordering, cancellation, client close,
post-parse invalid budget, and mutable-service-type bypass.
pkg/config,cmd/mo-service,pkg/embed,pkg/frontend,pkg/txn/client, andpkg/txn/clock.pkg/embed,pkg/frontend, andpkg/txn/client.the race detector; they use no sleeps, polling, retries, or weakened
assertions.
go vetpassed for every changed Go package; formatting, module-file, anddiff checks passed.
make buildpassed withCommitID=9a646c2a33.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 fix(frontend): invalidate revoked active roles in existing sessions #27737 scope.
Incident evidence:
https://github.com/matrixorigin/matrixone/actions/runs/33067372509/job/98502820591?pr=27758
Related: #27717, #27737, #27758