Repository navigation
Share JSON parsing in projections and preserve statistics on cancellation - #32980
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
Pass the current request only to bind-time JSON extraction so prepared external scans and view binding keep their established process behavior. Return cancellation directly from the JSON key sort and verify the partial diagnostics contract for failed SQL.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: e7802609de59841514f1daa34cfa669865c02037
Assessment: request_changes
The selected-row projection preserves row masks and leaves required output capacity available. The remaining cancellation gap is synchronous cleanup of large parse trees after cancellation has already been detected.
Model: gpt-6.2-sol / xhigh
Session: 01a1ee80-0d82-7030-a965-b51f496c3054 · slot 2 · generation 1
-
P2
pkg/container/bytejson/cancel_parse.go:64: Cancel JSON_EXTRACT after it has parsed a large LONGTEXT document containing many nested containers.
Impact: The parser delays returning the cancellation error while it recursively recycles every parsed group. The delay grows with the amount of JSON already parsed.
Evidence: The cancellation return at line 71 still runs n.Free(), which walks the entire tree in pkg/container/bytejson/bytejson.go:2081. The parser probe measured 104–145 ms from cancellation to return for a valid 12 MiB document. Bound synchronous cleanup on cancellation and cover the case where a large tree has already been built. See cancel-cleanup-wide.stdout and checks/1795409566510030809-2.json. -
P3
pkg/frontend/util.go:462: The request-context regression invokes bindSetVariableResultExpr to check SET rebinding.
Impact: The assertion can pass while the actual SET execution path regresses, and the helper duplicates a projection bind already exercised by the same test.
Evidence: The helper's only caller is pkg/frontend/frontend_context_test.go:224. Production SET calls getExprValueWithPrepareMeta and executes a synthetic SELECT through executeStmtInSameSession. Remove the redundant helper and assertion, or exercise the real SET path.
Validation:
-
28 focused Linux race tests passed across ByteJSON, projection, compile, frontend, and SQL functions. See focused-race-native.jsonl and checks/1795409781556583887-2.json.
-
The Go 1.27.1 long-number differential probe passed. See number-compare.stdout and checks/1795409174409332398-2.json.
-
Isolation preflight and git diff --check passed. Frozen CI records show successful Linux unit, coverage, static analysis, proxy BVT, and pessimistic multi-CN BVT jobs.
Limitations:
- The cleanup probe measures parser return latency on synthetic input. Statement-level KILL QUERY and disconnect timings come from the author's single-CN runs.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 3615089d4508d5944a8d320e086fcab2633bbbd0
Assessment: request_changes
The revision removes synchronous parse-tree cleanup on cancellation and preserves the projection memory budget. LIMIT binding still evaluates constant JSON expressions using the previous request’s context.
Model: gpt-6.2-sol / xhigh
Session: 01a1ee80-0d82-7030-a965-b51f496c3054 · slot 2 · generation 1
- P2
pkg/sql/plan/function/func_builtin_json.go:1114: On a reused MySQL connection, submit a valid query such asSELECT 7 LIMIT JSON_LENGTH(JSON_EXTRACT('{"n":[1]}', '$.n'))after the previous request has completed and its context has been canceled.
Impact: The live request can fail during planning withcontext canceledbefore it returns any rows.
Evidence:LimitBinder.foldConstantat pkg/sql/plan/limit_binder.go:174 passes the session process directly toConstantFold. The evaluator copiesproc.Ctxinto its child, and the new JSON cancellation check reads that context. Starting the next request updates the top context, while the completed request’s context has been canceled. Route LIMIT folding through the existing request-context helper and cover the case on a reused connection.
Validation:
-
Verified the frozen checkout, patch, pinned policy, native inputs, and isolation preflight. Accounted for all 19 discussion entries.
-
Eleven focused ByteJSON race tests passed, and the wide-tree cancellation regression passed 100 race repetitions. The parser probe measured 2.4–3.3 µs from cancellation to return on the synthetic documents. Successful group-heavy parsing allocated about 794 kB/op versus 431 kB/op for the legacy parser.
-
Frozen CI recorded successful Linux unit, coverage, static analysis, proxy BVT, and pessimistic multi-CN BVT jobs for this head.
Limitations:
-
The LIMIT finding is based on the source trace. Local planner, frontend, and MySQL probes timed out during build before executing. Commands, receipts, and logs are indexed in review-validation.md.
-
The parser probe measured component behavior. Production UPDATE latency, process RSS, and client-disconnect timing were not independently remeasured.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: a762397b47142a7be7bdfcb19374f22149ae703d
Assessment: request_changes
The guarded JOIN UPDATE reuses parsing within a bounded projection cache, and failed executions retain partial diagnostics from the terminal attempt. Two request-context defects remain. A live CREATE TABLE can inherit cancellation from a previous request, and EMA binding can report a canceled request as an invalid period. The earlier LIMIT example fails numeric coercion before JSON extraction.
Model: gpt-6.2-sol / xhigh
Session: 01a20682-9189-75a0-839a-f36d8b2372a5 · slot 1 · generation 3
-
P2
pkg/sql/plan/function/func_builtin_json.go:1114: On a reused MySQL connection, run SELECT 1 and then create a table with an integer column whose default is JSON_LENGTH(JSON_EXTRACT('{"n":[1]}', '$.n')).
Impact: The valid CREATE TABLE fails with MySQL error 1317 even though the current request is live.
Evidence: The MySQL probe reproduced error 1317. The same DDL planned successfully with a live process context and failed with a canceled previous process context. The CREATE TABLE binder takes that previous context at pkg/sql/plan/build_ddl.go:4068 and passes the session process directly to ConstantFold at pkg/sql/plan/build_util.go:1241. Use the current compiler context and the request-aware fold helper for the default expression. See binder-probes.jsonl and checks/1795428171088501629-2.json. -
P3
pkg/sql/plan/window_binder.go:1420: The current request is canceled while the planner folds a valid EMA period containing JSON_EXTRACT.
Impact: The binder replaces the interruption with an invalid-period error. MySQL clients lose the cancellation identity that maps to error 1317.
Evidence: TestWindowJSONConstantFoldUsesRequestContext accepts the expression with a live context and explicitly expects the invalid-period error after cancellation. The fold discards the context error, and pkg/frontend/protocol.go:284 classifies interruption from error identity. Propagate cancellation and deadline errors while preserving the existing diagnostic for invalid periods. See focused.jsonl and checks/1795428016213967619-2.json.
Validation:
-
Verified the frozen checkout, patch, whitespace and retained native inputs. Private /tmp and loopback preflight passed. See scope.log and preflight.log with receipts 1795427726033315374-2 and 1795427725148716299-2.
-
The full ByteJSON package passed under race. Focused tests passed for joined UPDATE sharing, row masks, memory budgets, retry and remote diagnostics, and all three repeated-connection window cases. See bytejson-race.jsonl and focused.jsonl with receipts 1795427789486228669-2 and 1795428016213967619-2.
-
Planner and MySQL probes reproduced the DDL regression and verified the LIMIT cast error. Focused JSON extraction cancellation, frontend planning and CLONE tests also passed. See binder-probes.jsonl and receipt 1795428171088501629-2.
-
Frozen CI recorded success for Linux unit tests, coverage, arm64 static analysis and pessimistic multi-CN BVT. All 21 discussion entries are accounted for in discussion-assessment.json.
Limitations:
-
EMA cancellation was exercised in the planner and traced through frontend error handling. No in-flight MySQL KILL QUERY was issued for that case.
-
Performance and disconnect timings come from the author's synthetic single-CN workload. Production behavior was not remeasured.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: fd94c404bd89efe9e0349ee3430efeb798da36da
Assessment: request_changes
The revision resolves the prior JSON default and EMA cancellation findings. The bounded projection cache and terminal-attempt diagnostics retain their validated behavior. RANGE partition validation still reads the previous request’s canceled context and rejects valid DDL.
Model: gpt-6.2-sol / xhigh
Session: 01a20682-9189-75a0-839a-f36d8b2372a5 · slot 1 · generation 3
- P2
pkg/sql/plan/function/func_builtin_json.go:1114: On a reused MySQL connection, run SELECT 1, then create a RANGE-partitioned table with successive bounds of 1 and JSON_LENGTH(JSON_EXTRACT('{"n":[1,2]}', '$.n')).
Impact: The live CREATE TABLE fails during planning with MySQL error 1317 (SQLSTATE 70100). The valid partition definition is rejected.
Evidence: The exact-head planner probe accepted the same DDL with a live process context and returned context canceled when only the previous process context was canceled. The MySQL probe reproduced error 1317. CREATE supplies the current context at pkg/sql/plan/build_ddl.go:3458, but the ordering check at pkg/sql/plan/partition_binder.go:186 evaluates with the session process. LIST uniqueness uses the same raw process at line 251. Use processForBoundExpr with the current context for both checks. See context-review.jsonl and receipt 1795433644967666450-2.
Validation:
-
Verified the frozen checkout, patch, native inputs and isolation preflight. See scope.log, preflight.log and receipts 1795433411635523083-2 and 1795433410851393997-2.
-
Exact-head planner and embedded MySQL tests passed for JSON defaults, CTAS and window binding. The EMA test verified cancellation and deadline error identity. See binding.jsonl and receipt 1795433626582377465-2.
-
Reused passing ByteJSON race, projection and diagnostic tests from the preceding head for unchanged paths. Frozen CI recorded success for Linux unit tests, coverage, arm64 static analysis, proxy BVT and pessimistic multi-CN BVT. See review-validation.md.
-
Accounted for all 23 discussion entries in discussion-assessment.json. The earlier LIMIT example fails numeric coercion before JSON extraction.
Limitations:
-
RANGE CREATE was reproduced through MySQL. LIST and ALTER ADD PARTITION were traced in source.
-
EMA cancellation was exercised in the planner. Production UPDATE performance and disconnect timings were not independently remeasured.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 2afc6b1fae7f232ba56a4397abf05b4b96ee2702
Assessment: approve
The revision fixes the stale request context in RANGE and LIST partition validation. The existing evaluator preserves row masks and output memory budgets while sharing JSON parsing across eligible joined UPDATE assignments. Failed statements retain partial diagnostics from the terminal execution attempt. The earlier LIMIT example fails numeric coercion before JSON extraction and does not demonstrate a cancellation regression.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
Validation:
-
Verified the frozen checkout, patch, pinned policy, native inputs, and isolation preflight. Accounted for all 25 discussion entries in discussion-assessment.json. Receipts and logs are indexed in review-validation.md.
-
Exact-head planner and MySQL tests passed for RANGE and LIST CREATE, ALTER ADD RANGE, JSON defaults, and window expressions. The planner also verified invalid bounds and current-request cancellation. See partition-and-binding.jsonl and receipt 1795445203637477247-2.json.
-
Exact-head planner and MySQL pagination probes confirmed matching coercion or syntax errors for the JSON LIMIT variants. Literal LIMIT and connection controls returned the expected result. See pagination-probe.jsonl and receipt 1795445327098007745-2.json.
-
Reused passing ByteJSON race and focused projection and diagnostics results for unchanged paths. Frozen exact-head CI passed Linux unit tests, coverage, arm64 static analysis, proxy BVT, and pessimistic multi-CN BVT.
Limitations:
- UPDATE timing, RSS, and disconnect measurements came from the author's synthetic single-CN workload. Production performance and disconnect latency were not independently measured.
🚫 Left the queue · pull request dequeued27 min in the queue, with no time running CI. So far
Reason Pull request #32980 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.
To get back in the queue
Merge conditions not met when it left the queue
Tick the box to put this pull request back in the merge queue (same as
2 merge conditions met
Times in UTC · dashboard · how the merge queue works |
…5fb9c5a68d8befb89bed8a2ee20d811b23c17ef
What type of PR is this?
Which issue(s) this PR fixes:
The reporter will verify the workload after merge.
What this PR does / why we need it:
A joined UPDATE that extracts several fields from the same LONGTEXT manifest could parse each document once per field. Processing a large document could also delay cancellation, and failed statements could lose statistics for work that had already run.
Performance and cancellation
On a local single-CN setup with 5,000 synthetic documents totaling about 897 MB, wall time for the seven-field UPDATE fell from 6.332–6.369 s to 1.097–3.438 s with an upper bound and from 6.757–6.797 s to 1.160–1.569 s without one. All 32 timed SQL runs matched the expected results row by row. In the 100-row window, the wide manifest scan remained at 100 rows and 17.11 MiB on both revisions. Peak query-domain memory for the seven-field case fell from 786.21 to 773.33 MiB, while peak sampled process RSS across the timed sequence rose 8.3%.
On the same synthetic workload, each cancellation action was measured once per revision. Time from action to server-side statement completion fell from 543.78 to 29.86 ms for
KILL QUERYand from 766.96 to 372.35 ms for TCP disconnect. Both statements rolled back with zero writes, subsequent queries succeeded, and their failed statement records retained partial scan counts and observed operators. These measurements came from a local single-CN setup with direct TCP connections.Validation
go vet, and fast lint also passed.CI repair validation
c2060e760afa, the JSON key sort returns cancellation directly and keeps keys paired with their values. A duplicate-key execution failure now asserts partial statistics and leaves the original row intact. The compile-failure control asserts that no execution evidence was published.molint,golangci-lintandgo vetpassed.c2060e760afa. Passing CI Prior CI failuresReview fix validation
39f21601217b, the full ByteJSON, colexec, projection and SQL function Go packages passed on Darwin/arm64. Focused race tests,go vet,molintand incrementalgolangci-lintpassed.func_json_extract_join_update.sqlstatements on the same fresh single-CN fixture matched the expected results, rollback and teardown.BenchmarkProjectionJSON, 1,024 rows and three local repetitions per mode. At the median, dense seven-field extraction took 4.3 ms with sharing and 25.6 ms with the ordinary evaluator. Sparse CASE took 13.7 ms and 13.6 ms respectively, with about 4.85 MB of Go heap allocation per batch in both modes.Rebase validation
f1ffbaaff35d. The projection executor keeps the JSON binding alongside the current Vector API. The previous three review fixes remain ince5aba01e490.go vetpassed. The existing JOIN UPDATE SQL matched expected results, rollback, and teardown twice over MySQL on one single-CN fixture. The statement diagnostics integration test passed.TestSQLTaskAlterAfterTriggerOnRealStorage/overlap_cancelexpected 1 during the setup UPDATE. Coverage aggregation and CI Required then failed. On the rebased head, the parent test and all subtests passed three Darwin/arm64 runs with-short -tags matrixone_test -covermode=setand coverage scoped to four packages. The new Linux run will verify the rebased head. Previous coverage failureCI refresh validation
e218f94ba2. All ten patches are unchanged according togit range-diff.bdcb2e74cc, focused ByteJSON, colexec, projection, and SQL function tests andgo vetpassed.TestIssue29572LogicalViewAuthorizationpassed three times on Darwin/arm64 with-short -race -tags matrixone_test.Guarded JOIN UPDATE and deep-path validation
eec32c74d73b,TestProjectionJSONPlannedJoinedUpdateverified one parse per selected LONGTEXT document for two guarded assignments. Focused ByteJSON, colexec, projection and SQL function tests passed on Darwin/arm64, along withgo vet,molintand fastgolangci-lintfor those packages.TestStatementDiagnosticsSQLalso passed, including the compile- and execution-failure cases.BenchmarkJSONQueryDeepSimplePathsused two simple paths at depth 512. Median local runtime with cancellation checks fell from 388 to 12 µs/op over three repetitions per revision. This measures path traversal on Darwin/arm64. The full Linux suite passed on the preceding head. Previous CIdea4f40b17d0and kept main’s physical row selection and MPool accounting.Projection rebase validation
c180b993e6b9rebases ontod9a43b3156dd. The projection keeps main’s VALUES warning-row offset and the PR’s JSON frame. The planned JOIN UPDATE parse-count test, physical selection, cache admission, deep-path cancellation, and partial diagnostics checks passed on Darwin/arm64. The MySQL ENUM/SET assignment regression, focusedgo vet, fastgolangci-lint, and the Loom artifact check also passed.TestSnapshotPublicationSkipsExternalTables/no_publication. The runner’s memory admission guard confirmed 1,053,282,304 available bytes against a 1,073,741,824-byte reserve and rejected a 24-byte scan-selection request after restore. The focused case passed three times oneec32c74d73band once onc180b993e6b9with-short -tags matrixone_test -covermode=setand four instrumented packages on Darwin/arm64. The rebase starts a new full Linux run. Failed coverage jobStatic analysis follow-up
c180b993e6b9, Linux SCA reportedSA1012for a nil context in simple JSON traversal andpreallocfor the planned JOIN UPDATE test. The fix passes the cancellation check explicitly and preallocates the test results. The traversal order, cancellation interval and test assertions are preserved. Failed SCA jobprealloc,staticcheckon ByteJSON and colexec. Localgo vet, ByteJSON, JOIN UPDATE plan, selection mask, and final-row cancellation tests passed before rebase. The wider local lint run timed out while loading packages.9fbdc258611brebases the twelve equivalent patches ontofebc2b472e15, which adds lock-read diagnostics. The rebased frontend, compile and MySQL statement-diagnostics regressions passed. Local depth-512 traversal medians from three interleaved samples were 9.11 to 9.28 µs/op for ordinary traversal and 9.15 to 9.16 µs/op with cancellation polling.Projection memory budget
081a75adfdd2, both results fit with an execution account, inherited physical admission, and a tightly capped base pool. Base-pool scratch retains parse sharing and leaves the off-heap cap available for required results.BenchmarkProjectionJSONsamples at 1,024 rows, median dense seven-field times were 5.14 ms with sharing and 31.39 ms with ordinary evaluation. Sparse CASE allocation stayed around 4.84 MB per batch in both modes.Vector ownership rebase
4cadd4f2f6ed, where each Vector has a single MPool owner. One7802609de59, the selected projection opens and releases the JSON frame around evaluation of the physical rows. The regression checks one parse per selected row across both fields, skips malformed masked rows, and verifies cleanup when a selected row fails.Cancellation cleanup
3615089d4508, long cancellable JSON parses leave their temporary tree to Go GC. Cancellation during parsing or encoding and replacement of duplicate keys no longer walk a discarded subtree to recycle groups. The frontend binding test retains its live-request, canceled-request and context-restoration checks after removal of its test-only SET helper. Review findingsJSON window constant binding
4cadd4f2f6ed9and reviewed head3615089d4508use the same LIMIT binder, which applies pagination's numeric coercion to the JSON function's arguments before JSON extraction can execute. ReviewNTH_VALUE, theEMAperiod check, andRANGE INTERVALnormalization. Commita762397b4714evaluates those JSON expressions in a child process with the current request context. Each query now returns its expected rows on the same connection.TestWindowJSONConstantFoldUsesRequestContext,TestFrontendExpressionContextAcrossRequests, and targeted pagination, window and publication binding controls. The planner test also checks current-request cancellation and that the original session process context is preserved. Reused successful Linux unit, coverage, static analysis and BVT results from3615089d4508for the earlier changes. Previous CIgo vetand repository-pinnedmolint checkpassed for the planner and embedded test packages. The separategolangci-lintand race runs stopped during local build.JSON defaults and cancellation during binding
fd94c404bd89uses the current statement context when folding JSON defaults in DDL. It preserves cancellation and deadline errors while evaluating window indicator periods. Invalid periods retain the existing diagnostic. Reviewgo vetand pinnedmolint checkand incrementalgolangci-lint. Reused the Linux unit, coverage, static analysis and multi-CN BVT results for the preceding heada762397b4714. This run used deterministic context injection to test planning cancellation. Previous CIJSON bounds in partition DDL
2afc6b1fae7fevaluates JSON expressions in RANGE ordering and LIST uniqueness checks under the current request context. The planner regression reproduces both failures onfd94c404bd89and verifies on the new commit that valid bounds succeed, invalid bounds retain their diagnostics, and cancellation of the current request propagates. Reviewgo vet, pinnedmolint check, and incrementalgolangci-lintpassed. The planner tests exercise cancellation through deterministic context injection.