Repository navigation
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? |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Re-reviewed the exact head 2dedfc3 against fetched origin/main 7ffce04. The complete 62-file diff and the digest lexer/parser/function, process-codec, protobuf, and remote-protocol call chains were inspected. Pure-Go mysql_digest tests and git diff --check passed. Broader parser/process tests were blocked by missing local CGo dependencies such as jemalloc.h and usearch/gosigar constraints, not by assertion failures.
[P1] MORPC version 68 is already allocated on current origin/main.
Files: pkg/defines/const.go:106; pkg/sql/compile/remoterun.go:2078-2082; pkg/sql/plan/function/function_id.go:846.
Trigger: during a rolling deployment, the STATEMENT_DIGEST planner sends a remote scope to a CN built from current origin/main. The PR changes MORPCVersion68 to STATEMENT_DIGEST and gates peers at version 68, but current origin/main already uses MORPCVersion68 for strict-write GROUP_CONCAT and does not contain function ID 579. Such a peer advertises version 68, passes the new gate, and then rejects the unknown function during remote executor construction. This breaks the fail-closed mixed-version contract. Rebase onto current main, allocate a fresh version after the current latest value, and update the constant, gate, boundary tests, RFC, and exact RFC link together.
[P1] max_digest_length resolver failures are silently converted into the default.
Files: pkg/vm/process/process_codec.go:172 and 502-525; pkg/sql/plan/function/func_statement_digest.go:89-117.
Trigger: while encoding a remote pipeline, the resolver returns an error, an unsupported type, or an out-of-range value. resolveMaxDigestLength drops that failure and returns MaxDigestLengthSet=false. After decode the remote process has no resolver, so statementDigestMaxLength falls back to 1024; the local evaluator contract instead returns the resolver/type/range error. The remote query can therefore succeed or hash a different prefix instead of preserving the error. Propagate or preserve the failure before dispatch, and align process-codec tests with the function error contract.
[P3] The compatibility comment is stale.
File: pkg/pb/plan/string_literal_form.go:205-206.
The comment says StatementDigestFunction requires MORPC v67, while the actual gate and boundary tests require v68. A maintainer following the comment can choose the wrong rollout boundary; update it to v68.
No P0 found. I checked the prior iamlinjunhong P2/P3 findings in review threads and the PR conversation; there is no explicit author reply corresponding to them. New commits, bot comments, and unrelated comments were not treated as replies. The current P1 findings require REQUEST_CHANGES. GitHub reports 27 terminal checks and mergeability CONFLICTING.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed revision: 2dedfc3c32dd497b77e4f47927efffd651270cd9.
[P2] Allocate a fresh capability for STATEMENT_DIGEST.
remoterun.go:2078 admits the new function at protocol >=68. Authoritative main already advertises 68/69 for GROUP_CONCAT strict-write reporting / bounded RANK while lacking STATEMENT_DIGEST function 579. A legitimate main predecessor therefore satisfies this threshold but cannot execute the dispatched expression; its function lookup rejects the unknown identity. This concerns main/predecessor compatibility, not arbitrary unmerged-branch interoperability.
Merge current main, allocate the next unused cumulative version, update the gates and compatibility tests, and use the actual predecessor allocation as a rejection control.
The RFC also explicitly leaves independent design approval pending and incorrectly describes 68 as dedicated to this feature. Obtain approval for the corrected revision before implementation approval. Review stops at this design/compatibility gate; this is not a blanket lexer/implementation audit. Current-head CI is green.
explain to me why this is not a merkle hash of the parse tree. why do you need to touch lexer, etc etc. |
In fact, we should already have the deparse method, at most what you need is a flag to deparse that output variable names in a "canonical" way, if deparse is not already doing that. I expect only a small amount of code to implement the feature by for example calling deparse. vast majority of the PR should be tests. |
|
MySQL's The current deparser plus canonical-literal rewriting handles only literal I tested this exact shortcut locally against MySQL 8.4.11. The test harness |
This is not the right design. Statement hash is never about compatibility. Do your separate design and scrap this one. |
fengttt
left a comment
There was a problem hiding this comment.
Esp the parse error. Either it is a parser bug that we should fix, or the digest should return error too.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 38bcbf83052b274013a312554d73fafaf3196451. I read the complete review/comment/thread history, compared the last aptend-reviewed head 2dedfc3c32dd497b77e4f47927efffd651270cd9, and reviewed the complete rewritten diff. The rewritten series is not descended from that old head, so the old MySQL-token-digest findings are obsolete; I independently verified that the prior resolver-error and exact-build remote-execution concerns have corresponding fixes in the new implementation. Two current blockers remain inline: the new public build-scoped SQL contract still has no traceably approved design revision after the maintainer explicitly requested a separate design, and the exact head reuses MORPC v85 even though current main already assigns v85 to integer-parameter coercion.\n\nValidation on the exact head: git diff --check; gofmt -d over changed handwritten Go files; make thirdparties; and, with the repository-required CGO include/link/runtime settings, go test ./pkg/vm/process ./pkg/sql/compile ./pkg/sql/plan/function -count=1 all passed. Current-head CI is terminal and green. I found no additional confirmed goroutine, lock, cleanup, unbounded retained-state, or fail-open mixed-build issue. GitHub currently reports the PR as conflicting with main.
| MORPCVersion83 int64 = 83 // bounded COALESCE character and binary result domains | ||
| MORPCVersion84 int64 = 84 // extended discrete percentile input types | ||
| MORPCLatestVersion = MORPCVersion84 | ||
| MORPCVersion85 int64 = 85 // MatrixOne-native MO_STATEMENT_HASH function |
There was a problem hiding this comment.
[blocking: protocol allocation] Current main already defines MORPCVersion85 as shared integer-parameter coercion, while this exact head defines the same cumulative capability number as MO_STATEMENT_HASH support. Reproduction: git show origin/main:pkg/defines/const.go reports v85 for integer coercion, and merging this head produces the conflict at this line. A current-main CN can therefore truthfully advertise v85 without function ID 581; although the new v86 dispatch check fails closed, this head and its boundary tests still encode a protocol history in which v85 meant statement-hash function support. Rebase, preserve main v85, allocate only a fresh capability for the complete statement-hash wire contract (v86 is currently the next free value), and update the comments/tests/design together.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Re-reviewed the complete PR diff at exact head 38bcbf8, based at 480b917, after syncing origin/main to d9609d7. All 36 reported checks are terminal and passing. No P0 found.
P1: MORPC v85 is already allocated on current main
pkg/defines/const.go:123-124 reassigns MORPC version 85 to MO_STATEMENT_HASH and advances the latest version to 86. The fetched origin/main already uses v85 for the IntegerParameterCoercion contract (pkg/sql/compile/remoterun.go:2181 and pkg/sql/compile/integer_argument_protocol.go:37,53). A mixed or rolling deployment therefore has two incompatible execution contracts under the same protocol number, so capability negotiation cannot distinguish them. In addition, this head gates the hash feature on v86 (pkg/sql/compile/remoterun.go:2222-2226 and pkg/sql/compile/statement_digest_protocol.go:39-46), while current-main workers advertise only v85. Allocate fresh protocol versions after rebasing and update all dependent gates and tests.
P1: SQL-mode resolver errors are dropped across ordinary forwarding hops
pkg/vm/process/process_codec.go:251-258 forwards only StatementHashExpectedBuildCommitID when captureStatementHash is false; it omits StatementHashSQLModeError and StatementHashSQLModeErrorDetail. Trigger: the coordinator sql_mode resolver fails, an initial RemoteRun scope without MO_STATEMENT_HASH reaches CN A, and CN A later forwards a descendant scope containing MO_STATEMENT_HASH to CN B. The deferred resolver error has been lost by CN B, so ResolveSQLMode can consult the worker-local resolver or fallback and hash under a different SQL mode instead of surfacing the original error. This contradicts the placement-invariant contract documented at pkg/vm/process/process_codec.go:635-637. Preserve both error fields across every forwarding hop, or fail closed before the downstream hash path; add an ordinary-hop-to-hash-hop regression test.
I also checked the previous review, inline threads, and PR conversation. There is no concrete author reply addressing the prior P2/P3 findings; the later design discussion is not a reply to those findings. The current P1 findings require REQUEST_CHANGES.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Re-review of exact head 9b706af against the fetched current origin/main. GitHub reports all 36 checks terminal with no failing check, but the PR is currently CONFLICTING.\n\nNo P0 found.\n\n### P1 — receiver accepts MO_STATEMENT_HASH with the wrong protocol epoch\n\nFiles: pkg/defines/const.go:126; pkg/sql/compile/remoterun.go:2248-2252 and 295-296; related sender probe: pkg/sql/compile/statement_digest_protocol.go:39-40.\n\nThe current origin/main already assigns MORPCVersion88 to canonical vector HLL_ADD_AGG (origin/main:pkg/sql/compile/remoterun.go:2012-2018), while this head reassigns the same cumulative number to MO_STATEMENT_HASH. More importantly, the sender probes a destination at MORPCVersion89, but the receiving decodeScope path only calls validateRemoteExpressionPipelineProtocol, whose MO_STATEMENT_HASH gate is v88. Trigger: the sender successfully probes a v89 worker, the worker is downgraded or replaced by a current-main v88 worker before the pipeline arrives, and that receiver accepts the function because 88 >= 88. Its pre-change binary has neither function ID 581 nor the v89 process-info/build and deferred-error contract, so remote executor construction fails with an unknown function instead of rejecting the pipeline at the protocol boundary. Rebase onto current main, preserve its v88 HLL allocation, allocate fresh versions for the complete hash contract, and make the receiver gate the same complete v89-or-later contract; add a probe-then-downgrade receiver regression.\n\n### P3 — stale capability comment\n\nFile: pkg/pb/plan/string_literal_form.go:272-273.\n\nThe added comment says StatementHashFunction requires v86 and the build/error transport requires v87, but the implementation gates these contracts at v88 and v89. Update the comment and design/test references so rollout diagnostics do not use the wrong epochs.\n\nValidation: git diff --check passed; the focused tests in the PR cover the sender probe but not the receiver-side downgrade race.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Re-review of exact head 60414218436f7d28f17f35976e0a159f92e6c83a against current origin/main a873bcf555aad2bf5eab0d1754f935454ba3043e (the PR base is 5e1e93ae35efc6eea54ae2935f68154493d6e95c). GitHub reports 36/36 check runs completed with no failing, cancelled, or timed-out conclusion. No P0 found.
P1 — MORPC v91 is already allocated on current main to canonical CHAR/JSON HLL keys
Files: pkg/defines/const.go:129; pkg/sql/compile/remoterun.go:2049-2055, :2266-2270.
Current origin/main at a873bcf555aad2bf5eab0d1754f935454ba3043e defines MORPC v91 as canonical CHAR/JSON HLL_ADD_AGG (pkg/sql/compile/remoterun.go:2029-2032), while this head reuses v91 for the complete MO_STATEMENT_HASH contract. In a mixed rollout, a current-main coordinator can send a CHAR/JSON HLL plan to this PR worker: the sender sees the worker advertising v91 and passes its v91 capability check, while this receiver only fences canonical vector HLL at v88 and accepts the text-HLL plan. It then executes the old raw-key semantics and can return incorrect aggregates. In the opposite replacement direction, a current-main v91 worker can pass the numeric protocol gate after a probe and then receive a MO_STATEMENT_HASH plan without function ID 581, so the incompatibility is detected after the protocol boundary. Keep current main's v91 allocation and allocate a fresh epoch for MO_STATEMENT_HASH after rebasing.
P1 — successful SQL-mode provenance is lost across an ordinary intermediate hop
Files: pkg/vm/process/process_codec.go:254-264 (especially line 264), :297, and the consumer at :642-646.
Trigger: the coordinator sends a hash-bearing process snapshot with SQL mode ANSI_QUOTES; an intermediate CN receives it, sends an ordinary no-hash scope, and a later CN evaluates MO_STATEMENT_HASH. When the forwarding Process has a resolver, the statementHashProcessInfoReceived branch preserves only the build ID and deferred error at lines 254-262, then unconditionally serializes resolveSqlMode(proc) at line 264. A resolver returning the intermediate mode (for example STRICT_TRANS_TABLES) replaces the immutable ANSI_QUOTES snapshot. After decode, ResolveSQLMode sees a non-frontend process with a non-empty SessionInfo.SqlMode and returns the replacement at lines 642-646, so SELECT "name" is parsed as a string instead of an identifier and silently gets a placement-dependent hash. If the deferred resolver error is present while the temporal flag is false, line 297 can also re-consult the local resolver and fail the ordinary hop eagerly.
The existing TestBuildProcessInfoGenericAndStatementHashSQLModeResolution (pkg/vm/process/process_codec_test.go:425-437) only calls BuildProcessInfoWithStatementHash again on the same decoded process; it does not decode ordinaryForward and hash on the next process. Preserve the received successful SQL-mode snapshot and deferred provenance on ordinary forwards, and add an ordinary-hop -> decode -> hash regression.
No additional confirmed P2/P3 findings.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 6041421. I read the complete review/comment/thread history, compared the rewritten implementation with my last reviewed head 38bcbf8, and audited the full current diff. The obsolete MySQL-token-digest findings do not apply to the new MatrixOne-native design, and the current implementation closes the earlier exact-build and resolver-error handling concerns. Three blockers remain inline: the current-main MORPC v91 collision, SQL-mode provenance loss through an ordinary intermediate hop, and the still-pending design approval. Validation: make thirdparties; go test ./pkg/vm/process ./pkg/sql/compile ./pkg/sql/plan/function ./pkg/sql/parsers/tree -count=1 (passed); git diff --check (passed). A temporary multi-hop regression deterministically reproduced ANSI_QUOTES being replaced by STRICT_ALL_TABLES; it was removed afterward. Current-head CI is green, but GitHub reports the branch as conflicting with main.
| MORPCVersion89 int64 = 89 // exact decimal literal and coercion semantics | ||
| MORPCVersion90 int64 = 90 // geodetic distance semantics and length-unit overloads | ||
| MORPCLatestVersion = MORPCVersion90 | ||
| MORPCVersion91 int64 = 91 // complete MatrixOne-native MO_STATEMENT_HASH remote execution contract |
There was a problem hiding this comment.
Blocking rolling-upgrade collision: current main bc523de already assigns cumulative MORPC v91 to canonical CHAR/JSON HLL_ADD_AGG keys, while this head advertises the same version for MO_STATEMENT_HASH. A current-main coordinator can therefore see this branch worker report v91 and dispatch a CHAR/JSON HLL aggregation; the worker lacks main’s v91 text-key semantics and can compute a different aggregate. The exact-build probe only protects statement-hash dispatch and does not protect HLL traffic in this opposite direction. Please rebase, preserve main’s v91 allocation, assign a fresh epoch (currently v92) to the complete statement-hash contract, and update every boundary gate/test/design reference together.
| statementHashResolverErr = append([]byte(nil), proc.Base.SessionInfo.StatementHashSQLModeError...) | ||
| statementHashResolverErrDetail = proc.Base.SessionInfo.StatementHashSQLModeErrorDetail | ||
| } | ||
| sqlMode = resolveSqlMode(proc) |
There was a problem hiding this comment.
Blocking multi-hop provenance loss: for a received process this branch preserves the origin build ID and deferred error, but this call still applies the legacy resolver precedence to the SQL-mode snapshot. I reproduced origin ANSI_QUOTES -> decode on an intermediate CN -> install an intermediate resolver returning STRICT_ALL_TABLES -> ordinary BuildProcessInfo: the forwarded SessionInfo.SqlMode becomes STRICT_ALL_TABLES. After another decode, MO_STATEMENT_HASH parses input such as SELECT "name" under the wrong mode and produces a placement-dependent result. The existing test asserts only the ordinary hop’s build ID and then hashes from the original decoded process, so it misses this path. Preserve the received SQL-mode snapshot (including the explicit-empty sentinel) unchanged through ordinary forwards, and add ordinary-forward -> decode -> hash coverage.
aunjgr
left a comment
There was a problem hiding this comment.
Request changes: the native statement-hash design has not cleared its required approval gate.
The versioned docs/design/20260918_matrixone_native_statement_hash.md explicitly remains a proposal awaiting independent approval. Its decisions include the public API and stability promise, fail-closed mixed-build remote execution, the adequacy of source commit identity as a compatibility fence, resource limits, and the tracking owner/issue for this separate native function. Historical approval of the earlier MySQL-digest implementation does not establish acceptance of this revised contract.
Please record acceptance of the exact native-hash design revision and close its listed blocking decisions before implementation approval. The repository's design-first contract requires stopping the implementation approval path while this gate remains open.
I verified that the design document is unchanged between the reviewed a3ce058 and current 650e0c8. This is a design-gate review, not a claim of full implementation approval. CI on the current revision is still running.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Re-review of the exact head da2bba4 against base df41cc2 and current origin/main 510e28e.
GitHub reports 36/36 check-runs completed with no failing, cancelled, or timed-out conclusion. The PR is open and mergeable, currently behind main. I found no P0. Four current P1 findings are posted inline:
- The constant fast path in StatementHash bypasses partial selection masks and can return a hash for masked rows or raise a parse error for a branch with no active rows.
- The receiver-side build-commit fence runs only for an active non-NULL callback, so zero-row, all-NULL, and all-masked remote batches can bypass the documented fail-closed dispatch gate after a worker replacement.
- RequiredRemoteExpressionFeatures detects StatementHashFunction, but persisted_ip.go never maps it to MORPC v92; a view using MO_STATEMENT_HASH can therefore be admitted without the durable protocol floor.
- The design document still explicitly says the native-hash revision is awaiting independent approval and leaves the listed API, rollout, identity, limits, and ownership decisions open. The previous review at 650e0c8 requested this gate, and the current head does not record its closure.
I checked the prior reviews, inline threads, and PR conversation. There is no explicit author response addressing the earlier P2/P3 findings. Regardless, the current P1 findings require REQUEST_CHANGES.
Validation: git diff --check passed. Focused local Go tests could not build in this isolated checkout because required CGo headers (usearch.h, roaring.h, xxhash.h, and jemalloc.h) are unavailable; the terminal GitHub checks above were also inspected.
| sqlModeErr error | ||
| ) | ||
|
|
||
| return opUnaryBytesToBytesWithErrorCheck(ivecs, result, proc, length, func(input []byte) ([]byte, error) { |
There was a problem hiding this comment.
[P1] The constant fast path bypasses the selection mask. The code above marks ignored rows NULL, but this callback is invoked once for a constant argument and appendRepeatedBytesResult fills every row without consulting selectList. Trigger: a literal such as MO_STATEMENT_HASH('SELECT FROM') is evaluated in a partially masked or short-circuit branch; an invalid input can raise even when no row is active, and a valid hash can overwrite rows that must remain NULL. Use the selection-aware repeated append or handle the mask before invoking the callback, and add a constant-plus-partial-mask regression.
| if len(input) > maxStatementHashInputBytes { | ||
| return nil, statementHashInputTooLargeError(len(input)) | ||
| } | ||
| if proc != nil && proc.Base != nil { |
There was a problem hiding this comment.
[P1] This is the only receiver-side build fence, but it runs only after the generic unary helper has selected an active non-NULL row. The design document's section 6 requires the destination/build check to be a scope dispatch gate even for zero-row or all-masked scopes. Trigger: the sender probe passes, the worker is replaced before execution, and a hash-bearing scope has length 0, all-NULL input, or IgnoreAllRow; the scope returns without comparing the received expected commit ID. Move this validation before row selection and add probe-then-replacement tests for empty and all-masked batches.
| if !features.MixedJSONBooleanEquality && isMixedJSONBooleanEquality(fn) { | ||
| features.MixedJSONBooleanEquality = true | ||
| } | ||
| if !features.StatementHashFunction && fn != nil && fn.Func != nil && |
There was a problem hiding this comment.
[P1] RequiredRemoteExpressionFeatures now detects StatementHashFunction, but pkg/sql/plan/persisted_ip.go:90-118 never maps it to MORPCVersion92. genViewTableDef uses this mapping to persist the protocol floor for catalog-bound views. Trigger: CREATE VIEW ... AS SELECT MO_STATEMENT_HASH(...) in a mixed-version deployment; the view is admitted with requiredVersion 0, so an older CN can read/dispatch it without the v92 admission fence and then fail on the unknown function or incompatible contract. Add the v92 mapping and a view authoring/read regression.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 0c5a947a867cb04d4eace17f37e80e9c44a6bf36 (merge base 3727c5c5436ca136d7b0312f75bc223a11692a85): REQUEST_CHANGES.
I read all 28 historical reviews and all 28 review threads, including the prior aptend review at 60414218436f7d28f17f35976e0a159f92e6c83a, then checked both the rewrite increment and the complete current diff. The old MySQL token-digest findings are obsolete after this PR was rewritten as a MatrixOne-native AST formatter hash. The current head closes the previously reported implementation blockers: the MORPC allocation now preserves v91/v92 and uses v93, multi-hop SQL-mode/build/error provenance is retained, constant selection masks no longer evaluate ignored rows, receiver admission fences zero/all-NULL/all-masked scopes, and persisted expressions require v93.
The remaining blocker is the design gate called out inline: this exact r6 design and the PR body both say independent approval is still pending, with no confirmed owner/tracking issue. That approval must cover the public API, build-scoped/non-persistent stability, fail-closed mixed-build rollout, source-commit-only compatibility identity, and resource-bound contract before the implementation can be approved.
Validation on the exact head: git diff --check; go test ./pkg/sql/plan/function ./pkg/vm/process ./pkg/sql/compile ./pkg/sql/plan ./pkg/sql/parsers/tree -count=1; focused go test -race ./pkg/sql/plan/function ./pkg/vm/process ./pkg/sql/compile -run 'StatementHash|Statement.*Hash|RemoteExpression' -count=3. Exact-head CI is green.
iamlinjunhong
left a comment
There was a problem hiding this comment.
[P1] Design approval and ownership gate is still open
File: docs/design/20260918_matrixone_native_statement_hash.md:3,6-7,293-295
Trigger: merge or deploy this exact head as-is. The document identifies revision r6 as “awaiting independent design approval”, leaves the proposed owner confirmation pending, and explicitly says the implementation remains a proposal until the listed decisions and evidence are reviewed. The PR description repeats that independent maintainer approval is pending. This change exposes a new public MO_STATEMENT_HASH API and MORPC v93 remote contract whose build-scoped stability, fail-closed mixed-build rollout, source-commit-only compatibility fence, resource limits, and ownership are user-visible compatibility decisions; without an authorized approval or amendment for this exact revision, merging can publish an unaccepted API/protocol contract.
Please record traceable maintainer approval (or an explicit amendment) for r6 and assign the tracking owner/issue before requesting implementation approval.
Rechecked exact head 0c5a947: the previous runtime P1 findings are closed by the current code/tests; no P0 or additional current P1 was confirmed. git diff --check passed. Historical review threads and PR conversation contain no author reply that closes the outstanding design gate.
fengttt
left a comment
There was a problem hiding this comment.
I still don't understand why statement hash need to touch pipeline. Everything is resolved after parsing, even before optimizer. It should touch NOTHING in pipeline.pb.go
Changes in that file, seems to be a problem that is not explained.
So is query plan pb. I don't see why this function has anything to do with pb |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Review of exact head 55fef8a against base ca71f51.
No P0/P1 is confirmed. I found one P2:
[P2] Valid multi-statement PREPARE/EXECUTE emits a false prepared-statement error log
File: pkg/frontend/mysql_cmd_executor.go:4399-4403, with pkg/frontend/session.go:2537-2549.
Trigger: on a session with no existing p, submit PREPARE p FROM "select 1"; EXECUTE p. GetComputationWrapper builds every wrapper before any statement executes. The new Execute fingerprint lookup therefore calls Session.GetPrepareStmt before the earlier PREPARE has installed p; the miss enters GetPrepareStmt error logging even though the request is valid and the later refresh at the execution boundary finds the newly created owner. The query can succeed, but it emits a misleading error-level log (and this lookup also runs when tracing is disabled). Please use a non-logging lookup or defer this fingerprint lookup to the execution-boundary refresh, and add a regression for the no-false-error-log case.
Validation: exact-head git diff --check and gofmt pass. Focused local tests were attempted but the isolated environment lacks jemalloc.h, usearch.h, xxhash.h, and roaring.h; the 29 GitHub checks were inspected with no failure. No author reply to this current P2 was found, so this review is COMMENT under the review policy.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 8780450cc7a748b9e832d3014ac4aeeb7093cd5c against merge-base 239fe81c82ae07a8c316576cac8555c445c92212; freshly fetched main was 087000434fedf24aaa7f0b2192c34c2aaaf3a9e8. Reviewed all 17 changed files, prior reviews/inline findings and their current applicability, and the formatter -> frontend/cache/prepared owner -> telemetry consumer paths. No subagents, no product edits.
Decision
REQUEST_CHANGES for one specific missing public-path validation gate, detailed inline. I have not confirmed a new runtime P0/P1/P2 defect. This is not a claim that the prepared implementation is broken; it is a required evidence gap for the feature's actual consumer surface.
Design judgment
I accept the architectural contract of r9 (matrixone-native-statement-ast-fingerprint-2026-09-23-r9, design blob 516c49698f3f27bdcb09195536b9fbb5be4376a9) for this narrow observability feature. Frontend owns pre-planning capture; existing cache/PrepareStmt owners retain only the value and attempted flag; existing telemetry owns publishing/aggregation. Reusing these owners is preferable to a second lexer, runtime SQL function, distributed hash evaluator, or new protobuf/version state. This records my independent technical judgment on r9, not blanket approval of an older design or implementation.
Accepted limits: this hashes formatter bytes including literals, not normalized query shape or semantic identity; it is neither anonymization nor cross-version stable. The 4 MiB bound limits emitted bytes, not all formatter CPU/temporary allocations/recursion. Aggregation intentionally clears the value. These limits are explicitly documented and internally consistent. #23024 is not implemented or closed by this PR. Implementation approval still needs the public validation below.
Historical findings
- MySQL lexer/digest grammar, SQL-mode/limit propagation, scalar selection masks, multi-hop provenance, build fences, MORPC collisions, persisted-expression gates, and stale protocol comments belong to implementations no longer present in this diff. They are obsolete through removal/scope change, not evidence that this PR now implements MySQL compatibility.
- The maintainer requests to reuse the AST formatter and avoid pipeline/query-plan protobuf changes are reflected in the current design.
- The latest construction-time PREPARE lookup false-error-log finding is addressed by the non-logging optional lookup; execution-boundary refresh remains authoritative. The focused regression covers absent construction-time owners and the genuine runtime lookup error. Old r6 design objections must not be carried forward without reviewing the materially different r9 contract.
Implementation, unhappy paths, performance, and test quality
- Q1: fingerprinting adds no AST ownership or background worker. Cache eviction occurs before borrowing; wrapper reset/clear drops metadata; existing cache/prepared/telemetry owners bound its lifetime. Q2: no new wait/lock/RPC chain; formatting is synchronous and cancellation is checked before/after, not preemptive. Q3: cached values are fixed-size hashes under existing cache/prepared limits; output overflow unwinds traversal and is not hashed. Formatter failure is marked attempted, avoiding a cache-miss/reparse loop.
- Checked trace-off -> trace-on cache handling, multi-statement PREPARE/replacement/deallocation, binary/text template reuse, rewrite/remap capture ordering, formatter panic/cancel/overflow, and unchanged telemetry serialization/aggregation/reset consumers. No additional confirmed lifecycle or compatibility blocker.
- Increment separates as production +514/-65, tests +705, document +137 (including alignment changes in the production count). The added test lines do not substitute for producer-to-consumer proof. Existing bound/failure/eviction/logging tests cover useful distinct internal contracts; the prepared tests currently mostly prove copying of injected strings.
- Performance is additional synchronous formatting + SHA-256 on uncached trace-enabled admission and on PREPARE even with tracing disabled; cache hits and EXECUTE reuse the captured string. Streaming escaping avoids a large expanded intermediate copy. I do not claim measured throughput/latency improvement or no regression: no relevant before/after benchmark was supplied. A small short-SQL/escaped-literal/cache-hit/PREPARE benchmark would quantify this tradeoff without a new load-test fixture.
Non-blocking cleanup: TestFormatStatementFingerprintDoesNotMutateAST compares output from the same canonical formatter before/after, so canonicalizing mutation during its first call would be invisible; assert original AST fields or an independent structural snapshot. Also consider extending the existing private cache insertion helpers instead of retaining another forwarding compatibility layer just for internal/test callers; remove the unreachable short-write checks in WriteByte/WriteRune (limitedWriteLength returns n or panics). None of these is presented as a demonstrated runtime failure.
Evidence and limits
Exact-head CI run 36396473136 reports terminal success with matching head SHA. The PR records exact-head full frontend tests (mo-cgo-test -count=1 -timeout=15m ./pkg/frontend, 27.278s) and a semantically unchanged formatter package pass; I reuse these as author evidence, not independent local execution. git diff --check passed locally. Downloading the UT job log timed out, so I do not claim independently verified named-test CI output. Local tree testing did not reach assertions: plain invocation failed loading libmo, and the prescribed wrapper rejected primary-worktree native artifact reuse because native inputs differ. No native provenance bypass, no live BVT pass, and no new race/performance run is claimed.
| prepared := &PrepareStmt{ | ||
| Name: "stmt1", | ||
| PrepareStmt: prepareBody, | ||
| statementFingerprint: "prepared-template-fingerprint", | ||
| statementFingerprintAttempted: true, |
There was a problem hiding this comment.
[P2] Prove the actual PREPARE-to-telemetry contract, not only copying an injected fingerprint
This test supplies "prepared-template-fingerprint" directly to PrepareStmt, just as the text EXECUTE test and refresh test supply synthetic owners/values. TestRecordStatementCopiesCapturedFingerprintToTelemetry likewise injects a wrapper string and stops at the in-memory StatementInfo. Consequently these assertions do not exercise capture in createPrepareStmtInSession, its before-planning ordering, actual EXECUTE, or publication to system.statement_info. Removing the producer capture would not make these copying tests detect the loss. The existing log/column_stmt.sql selects where statement_id = ''; external-table schema fixtures also do not assert the new value. There is no changed BVT/public-path case in this PR.
The repository testing contract requires public-path proof for a newly SQL-visible value, even when the column already exists. Please add the smallest real-frontend regression (reuse the telemetry fixture) that executes SQL and checks an identifiable non-aggregated statement_info row against an independent expected hash. Include a real PREPARE/EXECUTE template, two bindings that must retain the same fingerprint, and replacement by a different template that must change it; at the appropriate UT/client layer cover the pre-planning capture boundary instead of pre-filling the result. Keep one relevant absence/error control and reuse existing aggregation tests rather than duplicating every UT permutation. Record the exact selected case in normal comparison mode plus cleanup/same-instance rerun. This is a missing mandatory validation artifact, not a newly reproduced runtime defect.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 8e4cecc: APPROVE. I read the prior reviews and inline threads, checked the increment since the last review and the complete current diff, and traced formatter capture through frontend admission, prepared/cache ownership, execution-time refresh, and statement_info publishing.
The remaining non-outdated P2 validation finding is closed by the current changes: TestHandlePrepareStmtCapturesFingerprintBeforePlanning exercises the real PREPARE/planner boundary with an independent pre-planning hash, while test/distributed/cases/log/statement_fingerprint.sql checks actual nonaggregated telemetry rows for direct SQL, two bindings of one template, a replacement template, and failed missing EXECUTE with an empty fingerprint. The committed golden hashes for both template SQL strings match independent SHA-256 calculations. Earlier MySQL digest-function, remote-expression, and protocol findings are in code no longer present in this telemetry-only design; they do not establish defects in this head.
Independent exact-head validation: make thirdparties; make -C cgo; full go test ./pkg/frontend -count=1; full go test ./pkg/sql/parsers/tree -count=1; gofmt check; git diff --check — all passed. Current-head GitHub required CI is green. I found no blocking correctness, lifecycle, or bounded-output issue. The documented fingerprint remains formatter/build scoped and is not MySQL STATEMENT_DIGEST or anonymization.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed 8e4cecc. The frontend captures the bounded AST fingerprint before planning, stores it with prepared/cache owners, refreshes EXECUTE at the execution boundary, and leaves telemetry absent on formatter failure or missing prepared bodies. The design explicitly limits this to a MatrixOne-native observational fingerprint, not a stable MySQL digest. Focused formatter/owner tests and the public telemetry BVT cover the relevant paths; CI is green. No blocking issue found.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 8e4cecc, merge-base c69187e (current main d8152cb differs by unrelated View design docs). APPROVE. No subagents and no product edits.
I read all 19 changed files and the historical reviews/inline comments. The r9 design remains sound for its explicitly limited observability contract: frontend owns pre-planning capture, existing cached/prepared owners retain a fixed-size value plus attempted state, and existing telemetry owns serialization, aggregation and recycling. No second parser, cache, executor, protocol or hash state machine is introduced. This is formatter/build-scoped AST identity including literals, not MySQL STATEMENT_DIGEST, anonymization, query-shape grouping or a cross-version key; #23024 remains outside the implemented contract.
The previous blocking validation comment is now closed. TestHandlePrepareStmtCapturesFingerprintBeforePlanning calls the real PREPARE/planner boundary, deliberately mutates the AST at planner entry and checks independent pre/post hashes. The public statement_fingerprint BVT checks actual nonaggregated rows for direct execution, two bindings, replacement template and a failed missing EXECUTE with an absent fingerprint. I independently recalculated all three committed golden hashes. The nonmutation test now compares against a separately parsed structural snapshot, addressing the previous circular-oracle comment. Historical digest lexer, scalar function, protobuf and rolling-upgrade findings refer to implementations removed from this diff; the maintainer requests to reuse deparsing and remove pipeline/plan protobuf changes are fulfilled.
Closure review: bounded formatter -> frontend admission/rebuild -> cache and prepared replacement/deallocation -> RecordStatement -> telemetry clone/serialization/aggregation/reset. Challenged trace-off -> trace-on eviction before AST borrowing, attempted-but-empty results, same-request PREPARE/replacement/deallocation, string/identifier escape expansion, cancellation/panic/overflow, and pooled telemetry reset. Q1: existing owners release ASTs; fingerprinting retains only strings. Q2: no new asynchronous wait chain; cancellation during formatting is explicitly non-preemptive. Q3: 4 MiB emitted-byte bound and fixed-size retained hashes under existing owner limits; this is not a total recursion/CPU bound. No confirmed blocking correctness, compatibility, cleanup or growth defect.
Implementation, tests and docs were assessed separately: production +514/-65; tests/cases +930/-2; design +137. The public fixture adds a distinct producer-to-consumer oracle and reports clean teardown plus same-instance rerun; it is not just another injected-string assertion. Two nonblocking cleanup suggestions remain from the previous review: simplify the private cache forwarding layers, and remove unreachable short-write branches in WriteByte/WriteRune. They do not justify withholding approval. Additional formatting and SHA-256 cost exists on trace-enabled uncached admission and each PREPARE; EXECUTE/cache reuse copies the saved value. There is no measured throughput/no-regression claim. A small benchmark would quantify that documented tradeoff.
Evidence reused at this exact head: full frontend and parser-tree package passes; the recorded public BVT normal-comparison runs twice (19/19 each) with zero residual accounts/sessions; current-head CI run 36524942650 has terminal successful UT, coverage, SCA and compose checks. Local diff check and independent golden-hash calculations passed. I did not rerun equivalent cluster/package tests or claim new race/performance evidence.
fengttt
left a comment
There was a problem hiding this comment.
Can you run a TPCC test first, either on your local or daily, and see the cost of this?
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed exact head a133571f45dbf0f0bf48dd7de377a21fce854d2a against merge-base 83d82b8ee0cd694e0c6a7146902d74ae4dfb415a and the current origin/main.
I found no confirmed P0, P1, P2, or P3 issue. I traced the fingerprint from bounded AST formatting through direct statements, prepared statements, cached plans, multi-statement execution, telemetry publication, and session migration. The previously reported false prepared-statement error log is closed by the non-logging construction lookup and execution-boundary refresh, with focused and public PREPARE/EXECUTE coverage. Formatter cancellation, panic, output bounds, canonical variables, AST non-mutation, cache invalidation, and replacement/missing-owner cases are covered by the current tests.
The exact head has 29 terminal checks with no failure (13 successful, 14 skipped, 2 neutral), and git diff --check is clean. No inline findings.
What type of PR is this?
Which issue(s) this PR fixes:
Related: #23024. This PR records a MatrixOne-native statement AST fingerprint in telemetry. It does not implement or close the MySQL-compatible
STATEMENT_DIGESTrequest.Design contract: MatrixOne-native statement AST fingerprint
What this PR does / why we need it:
Records a SHA-256 fingerprint of the effective parsed statement AST in the existing
statement_fingerprinttelemetry field. It follows MatrixOne's AST formatter output for observability, including literal values; it is not anonymization, a normalized MySQL digest, or a durable identifier across formatter/build changes.The frontend captures the AST after hint/remap rewrites and before plan construction can mutate it, then retains lowercase hexadecimal SHA-256 with the prepared/cache owner. Prepared executions reuse the prepared-body template fingerprint, excluding bindings. Remote execution uses the frontend-captured value; no remote evaluator or protobuf changes are required. Capture is best-effort: empty output, formatter panic, cancellation, or output above 4 MiB leaves the telemetry field absent without failing an otherwise valid statement. This emitted-byte limit is not a total CPU, temporary-allocation, or recursion budget. Parse errors remain ordinary query errors. Existing aggregation is unchanged; aggregated rows do not carry a per-execution fingerprint.
Optional eager prepared-statement lookups remain non-logging when a statement is absent; execution-boundary refresh remains authoritative. Regression coverage exercises real PREPARE/planning, independent AST nonmutation, direct execution, two bindings of one template, replacement, and failed missing EXECUTE with an empty fingerprint. Public telemetry queries identify only the live writer session and require nonaggregated rows.
Rebased onto main
76862df5c89e8868bed5963c428f65b9eafb34b3. The formatter conflict preserves both bounded fingerprint output and main's complete-AST parameter-slot counting; the prepared binding/pruning regressions pass. Protocol, function allocation, and serialization files remain byte-equal to this base. The feature remains the same 19-path scope.Performance: formatting and SHA-256 add work on trace-enabled uncached admission and each PREPARE; EXECUTE/cache reuse forwards the saved value. This update adds no separate runtime mechanism. No throughput or performance-no-regression claim is made; no benchmark was run for this conflict-only integration.
Validation
7dbd2e2c32298689e6cad28e3e3749df663e36f2; base:76862df5c89e8868bed5963c428f65b9eafb34b3.make cgoandmo-native-provenance verify;make buildpassed. Binary version reports this head; SHA-2562a63fac215208b39c826e31d34294724d9169002669873fc79f267e1b426b268.GOWORK=off go test -mod=readonly -count=1 -timeout=180s ./pkg/sql/parsers/tree..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s -run '^(TestPreparedSourceBindingKeepsCurrentValuesAndOrdinals|TestPreparedSourceLayoutSurvivesPruning)$' ./pkg/sql/plan..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/frontend.go vetpassed for parser-tree, prepared plan and frontend. Configured golangci-lint 2.6.2 over changed tree/frontend packages with--new-from-rev=76862df5c89e8868bed5963c428f65b9eafb34b3passed with zero issues. Changed-Go gofmt,git diff --check, and conflict-marker checks passed.test/distributed/cases/log/statement_fingerprint.sqlpassed twice in normalmo-tester -n -g -o -p <case-path>comparison (default run mode) on a fresh standalone instance built from this head: 19/19 (14.258s), then same-instance 19/19 (11.720s). Independent post-run queries showed zero test accounts and live sessions after each run. SQL/result bytes were unchanged; no expected results were regenerated. The test-owned service was stopped and its ports released.