Skip to content

fix(frontend): refresh role rules across CN sessions - #30400

Merged
mergify[bot] merged 20 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/76e3cad40c0f2e6440216643a54eab8c437c28eea026d301dbfd1b05c23f8729
Oct 17, 2026
Merged

mergify[bot] merged 20 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/76e3cad40c0f2e6440216643a54eab8c437c28eea026d301dbfd1b05c23f8729

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Oct 16, 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:

What this PR does / why we need it:

A persistent CN1 session can retain an empty row-filter policy and return forbidden rows after CN2 adds a rule. Validate session rules against an account-scoped eight-table catalog proof including mo_role_rule. Active-role membership, rules and privilege reads share one statement-owned authorization snapshot A, independently of an older user data transaction. Its first data transaction consumes the completed admission; authorization reads remain independent read-only SI transactions at A.

Keep principal/generation, commit-minimum and final-publication checks; end/cancel invalidates statement ownership. Real implicit commits and replacement BEGIN renew the owner before continuing. Prepared refresh errors retain the known handle so EXECUTE/FETCH can release cursor accounting and pending parameters. The cross-CN PITR fixture waits for the writer's acknowledged commit to reach the reader before asserting remote authorization.

The latest repairs remove discarded AST construction for a single COM_QUERY containing a trailing, literal or comment semicolon, using the existing MySQL scanner for statement boundaries. Genuine batches retain eager syntax rejection and SQL-mode-aware continuation. They also reduce epoch/context bookkeeping, redundant cancellation adapters, prepared policy copies and lookup locking without omitting freshness or cleanup checks. No TTL, stale-empty-cache shortcut, relaxed authorization freshness, larger test deadline, new wire/catalog/configuration format or background worker is added.

Validation at rebased runtime 3f2326ea6f8b093a5316d72cd7279f6eba6e72d3 on official main b111224b0c624773389b390cd3cf1223126b6ee2 (Darwin/arm64, Go 1.27.1, CGO=1, matrixone_test):

  • Full frontend, MySQL parser, transaction client and disttae pass race/vet-all: 37.640s, 6.564s, 11.476s and 13.529s respectively. Incremental configured lint reports zero issues.
  • Four real cross-CN/prepared-lifecycle consumers pass together in 91.449s. They retain remote ADD/replacement/DROP, current authorization with older data, prepared owner/row-rule cleanup, and implicit TRUNCATE followed by same-packet continuation. Deterministic owner, cancellation, failure and eight-table sampling controls retain the recorded 100-repetition race evidence where source is unchanged.
  • Complete matched TCP protocol: 32 cells per revision, 64 first-use samples, 64 warmups and 192 measured samples. Both builds use the same harness, instrumentation and native inputs; default text-delimiter/text-literal cells are included. All six processes exit zero and every request validates its complete expected rows. The report retains throughput, latency, admission/snapshot counts, raw samples and startup waits.

Default performance acceptance remains OPEN. Earlier bounded pilots retain a repeatable residual loss; the new full matrix also records external compiler contention and large default-cell variance, so it cannot establish clean acceptance or justify calling the regression noise. Shared admission waits (4m51s for candidate preserve and 3m8s for baseline limited) are excluded from measured rounds. This publication delivers the verified source repairs and measurement evidence; it does not waive or resolve the outstanding default-performance feedback.

The versioned design and raw measurement manifests distinguish historical revisions, current-source validation and remaining acceptance work. Historical CI run 39017328791 succeeded at remote head 5db8b2eb5edfb3124ee9a0fa009ce2e0e073800e; it is not validation of the new repair head. New CI is pending this publication. Single-client measurements do not establish mixed-load capacity or production latency guarantees.

Design: revision 3. Current complete TCP matrix and raw evidence retain all samples and limitations.

@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 →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 16, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Oct 16, 2026
@iamlinjunhong
iamlinjunhong force-pushed the codex/loom/develop/76e3cad40c0f2e6440216643a54eab8c437c28eea026d301dbfd1b05c23f8729 branch from d3066da to e049862 Compare October 16, 2026 20:03
@iamlinjunhong
iamlinjunhong force-pushed the codex/loom/develop/76e3cad40c0f2e6440216643a54eab8c437c28eea026d301dbfd1b05c23f8729 branch from e049862 to 45cfea7 Compare October 16, 2026 21:15

@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.

Request changes: the reported performance regression is a merge blocker.

The PR's authenticated TCP report records throughput reductions of 2.9–4.4% under default settings, 31.6–32.1% with freshness preserved, and 41.4–41.8% under transaction-rate admission. These figures belong to the report's measured revisions/configurations; they are not a new measurement of the final merge head. They nevertheless demonstrate a material cost that has not been resolved or accepted.

The source exposes the underlying extra work: every request's role-policy freshness check calls GetPrivilegeCacheVersion -> GetLatestSnapshot, including warm/empty rule caches. That incurs transaction-rate admission and, when required, logtail waiting. Existing privilege-cache validation independently obtains the same class of catalog proof. Prepared-request deduplication only removes repeated role lookups within one request; it does not eliminate the added admission relative to base.

Please consolidate freshness/catalog proof ownership with the existing request/statement/transaction path and remove redundant admission without weakening cross-CN rule enforcement. Define safe reuse and invalidation for intervening commits, principal/cache-generation changes, multi-statement and nested authorization, existing transactions, errors and cancellation. A separate TTL cache, stale empty-cache shortcut, relaxed freshness, or a larger UT deadline does not establish a performance fix.

Before approval, provide matched base/head authenticated TCP measurements using the same harness, runner and settings: default, freshness-preserving and rate-limited modes; text and binary; first-use and warm sessions; rules present/absent and admin/non-admin. Include throughput, latency and snapshot/admission counts, and demonstrate no material regression while retaining the cross-CN ADD/replacement/DROP and fail-closed/resource-cleanup regressions.

The current prepared-pagination UT failure is confirmed to exhaust its shared three-minute context. That particular timeout has not been causally attributed to this PR without a matched base/head comparison; it is separate from the performance regression already recorded in this PR's report.

@iamlinjunhong iamlinjunhong mentioned this pull request Oct 17, 2026
1 task done

@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.

Reviewed all 34 changed files against merge-base db1bcc19f95078ce9d960e13b35c2877b9351f28, at head 5db8b2eb5edfb3124ee9a0fa009ce2e0e073800e. Request changes: two performance items remain.

The ownership direction is sound: the transaction client remains the admission authority; the statement owns one authorization snapshot/proof; marked authorization readers use independent read-only SI transactions at A; data creation consumes the admission once. I traced normal/zero-proof/error paths, prepared EXECUTE/FETCH cleanup, principal/generation changes, staged SQL, replacement BEGIN/implicit commits, cancellation and transaction queue cleanup. No additional confirmed correctness/security/liveness defect was found in this pass.

Previous feedback is only partially closed. The known prepared handle is now preserved on refresh failure and the six cleanup scenarios pass. Sharing admission removes the earlier freshness-preserving/rate-limited regression, and the expanded report addresses the requested measurement matrix. However, the default-path regression remains explicitly measurable and has not been accepted by the requester. In addition, single-statement COM_QUERY now pays a discarded full parse whenever the SQL contains a semicolon, including a trailing delimiter or one inside a literal; the supplied TCP benchmark omits this path. See the two inline findings.

Validation and evidence:

  • Built matching native dependencies in an isolated clean review worktree. Local Darwin/arm64, Go 1.27.1, CGO=1, matrixone_test focused race runs passed for the five snapshot-admission/authorization-snapshot tests and seven frontend epoch/parser/freshness/failure-cleanup tests. No production edit was made.
  • A separate normal-mode reviewer probe measured the extra single-statement preparse: select id from app.t order by id; costs about 2,059 ns, 2,864 bytes and 31 allocations per call; select ';' as x costs about 1,323 ns, 2,400 bytes and 18 allocations. Both return staged=false. These are isolated helper costs, not end-to-end throughput measurements. The probe was removed from the source worktree after measurement.
  • Reused current-head successful CI run 39017328791 for full UT/race, SCA and multi-CN BVT. Downloaded its UT log/summary and verified the exact checked SHA and named statement-epoch, prepared-owner/migration and account-PITR successes. Broad CI was not rerun locally.
  • Recomputed all 24 paired warm-performance cells from the 240 raw samples. All 14 production-file hashes in the measured candidate manifest match the retained measured implementation 0a26949273e86b1996721cd55b75bb278ee51419. Later relevant edits are replacement-BEGIN handling and main's connection-charset initialization; the warm SELECT admission path is unchanged. The figures remain measurements of the report's actual revisions, not a new benchmark of this final head.
  • Production delta: 14 files +982/-84; tests: 14 files +1287/-10; documentation/measurement artifacts: 6 files +826/-0. The new two-CN tests reuse the existing authenticated base fixture and use minimal data. Reviewed the changed PREPARE expectations and PITR causal wait: the former asserts complete fresh result sets while retaining stale-handle rejection cases; the latter retains the same connection/handle and waits for the actual acknowledged commit frontier.

Design/lifecycle audit: statement/token storage is bounded by the statement; end/cancel owns token invalidation; transaction failures retain the existing closeUnadmitted/abortCreatedTxn owners. Limiter, readiness, logtail and queued-admission waits retain cancellation/close edges, with no new epoch lock held across I/O. No catalog/wire/config migration is added. The core design is acceptable, but the performance acceptance gate is not yet met. Local evidence and the temporary probe are retained under /tmp/mo-review-30400-evidence.

Comment thread pkg/frontend/mysql_cmd_executor.go Resolved

@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.

Request changes at e72ee1734b252591a8cfba6cc7517f0421bbcfee against merge-base b111224b0c624773389b390cd3cf1223126b6ee2.

[P2] Default TP performance acceptance remains unclosed. This retains the existing performance finding, rather than opening a duplicate thread. The three historical independent process pairs in statement-authorization-hot-path-results.jsonl still show −0.63%, −0.65% and −1.21%; I recomputed the pooled nine-round medians as 9,801.77 → 9,705.04 requests/s (−0.99%). Those measurements have historical inputs and are not a measurement of this final head. The current complete replacement matrix records external compiler contention and very large bidirectional variation, so it cannot establish that the default regression has been removed. I am not attributing its large negative percentages to a production-code regression.

Please close this existing requirement with matched base/current-source runs on an uncontended runner, retaining first-use/warmup separation, independent process pairs, default no-rule/rule and reader/admin cases, and text/binary plus delimiter/literal variants. If the residual cost remains, reduce the hot-path cost while preserving current authorization and cancellation semantics. Preserve/limited improvements do not waive the separate default TP requirement. The delivery report, PR description and author's reply correctly keep this gate open.

The other prior finding, discarded full-AST parsing for a single COM_QUERY containing a semicolon, is fixed. Boundary detection now reuses the existing MySQL scanner; genuine batches retain eager syntax checking. I checked the lexical edge cases, SQL-mode continuation and the added protocol cells. The resolved parser thread can remain resolved.

Design/implementation review covered all 43 changed files, separately accounting for production (16 files, +1,214/−107), tests (17, +2,061/−10), and documentation/measurement (10, +1,498). The statement epoch, transaction admission and engine catalog proof have distinct responsibilities; admission/capacity and catalog freshness remain with their existing authoritative owners. I found no additional confirmed correctness blocker in this review.

Closure Ownership / failure / bound checks
Frontend epoch and prepared state End/cancel, waiter publication, principal/generation invalidation, old-data/new-authorization separation, replacement BEGIN and implicit-DDL continuation; failed EXECUTE/FETCH cleanup
Transaction client One paid data admission, independent SI authorization readers at A, A.Prev readiness, later waiter frontier, token reuse/restart, End during direct publication, limiter/readiness/queue waits, failed-creation cleanup
Engine proof Eight-table identity/version/pending-apply checks, zero/error proof fallback, subscription cancellation, bounded proof state; idle timestamp sharing does not replace freshness checks

Tests include real two-CN protocol entry points with explicit catalog-commit barriers, alongside targeted lifecycle controls. Their oracles, cleanup and fixture costs were reviewed separately from implementation size.

Evidence: all 33 recorded changed Go source/test hashes, including the harness, match this head. I independently parsed the 320 replacement samples: 64 first-use, 64 warmup, 192 measured, with zero recorded request errors. CI run 39044811112 is successful; the UT log confirms checkout of this exact head. This review reused current CI and recorded validation; I did not rerun local tests or performance benchmarks. Green CI does not close the performance gate.

@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.

Approved at e72ee1734b252591a8cfba6cc7517f0421bbcfee.

The completed review covered all 43 changed files, including design/ownership, cross-CN authorization consistency, transaction admission, prepared-statement cleanup, cancellation/queue paths, parser boundaries, and the quality of the added tests and measurement evidence. No other confirmed blocking issue remains from that review. The discarded single-statement AST parsing issue is fixed.

The approximately 1% historical throughput difference is retained as a non-blocking observation: the available process-pair evidence and confounded latest matrix do not establish a current-head regression strongly enough to justify Request Changes. This approval does not assert literally zero overhead. The original performance thread has been updated with this recalibration and resolved.

I rechecked that the head is unchanged and that CI Required, build, Ubuntu UT, SCA, and the active proxy/pessimistic multi-CN BVT jobs are successful for this head. This decision reuses the completed source review and current validation evidence; no new local test or benchmark run was performed.

@mergify

mergify Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-17 17:45 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-17 18:20 UTC · at 2bd6b735865e5a1bd6e866a24f119a3d2af432c0

This pull request spent 34 minutes 55 seconds in the queue, with no time running CI.

Reason

Pull request #30400 has been dequeued

Queue conditions are not satisfied:

  • -conflict [📌 queue requirement]
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue rule main]
      • any of: [🛡 GitHub branch protection]
        • check-neutral = CI Required
        • check-skipped = CI Required
        • check-success = CI Required

Hint

You 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.
If you do update this pull request, 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.

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

@mergify

mergify Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-17 19:13 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-17 21:45 UTC · at 7d93ece8290aba0dc3bba9682ae16ece0f8c5494 · squash

This pull request spent 2 hours 32 minutes 2 seconds in the queue, including 49 minutes 32 seconds running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
ci — e0248fdb Deployed Oct 17, 2026 by mergify[bot]
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 size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants